Showing posts with label mobile web. Show all posts
Showing posts with label mobile web. Show all posts

Remove click delay on mobile browser

mobileClick.js - jQuery plugin that create self event 'mobileclick', not invoke 'click' event, not interfering in propagate stack of events. You need just bind 'mobileclick' event to you html element:
$('you-element-selector').bind('mobileclick', function() {
    alert('test me');
})
// or
$(document).on('mobileclick', 'you-element-selector', function() {
    alert('test me');
})
github project: mobileClick

Mobile Web: Set cursor position to the end of a text field.

If you want to place the cursor at the end of the text box, simply add the following code :
 
elm.addEventListener("focus", function() {this.value=this.value}, false);
 
 
But if your code is designed for mobile browsers, it will not work.
Use this code:
 
elm.addEventListener("focus", function(){
             if(this.setSelectionRange) {
           var _this = this;
           setTimeout(function(){
                                    _this.setSelectionRange(9999, 9999);
                                }, 0);
             } else
                 this.focus();
   }, false);
 
 
Why do you want to do this?
If your site has the direction="RTL", then after the text field gets focus, the cursor is placed not at the end of the field and in the beginning.
So you can't add text to the end and erase text by backspace.