mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-20 22:30:59 +00:00
On touch devices, 3rd party code that used href='#' links and onclick handlers weren't working because our live("vclick") link handler in jquery.mobile.navigation.js was calling preventDefault() on the vclick event.
For vclicks dispatched via touchend, calling preventDefault causes mouse clicks to be suppressed. This is why the 3rd party onclick handlers weren't getting triggered. For vclicks dispatched by a real mouse click this isn't a problem.
The fix basically removes the preventDefault() call from the live("vclick") handler and places it in a real live("click") handler. This allows the mouse event to get dispatched and trigger 3rd party click handlers, and still call preventDefault to prevent the link from being followed.
This commit is contained in:
parent
14fbe8b164
commit
3ce228e3f2
1 changed files with 11 additions and 2 deletions
|
|
@ -717,7 +717,9 @@
|
|||
//path.get() is replaced to combat abs url prefixing in IE
|
||||
if( url.replace(path.get(), "") == "#" ){
|
||||
//for links created purely for interaction - ignore
|
||||
event.preventDefault();
|
||||
//we'll let our live "click" handler call event.preventDefault()
|
||||
//on this event so that 3rd party code clicks handlers can
|
||||
//get called.
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -805,5 +807,12 @@
|
|||
else {
|
||||
$.mobile.changePage( $.mobile.firstPage, transition, true, false, true );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( "a" ).live( "click", function(event) {
|
||||
//preventDefault for links that are purely for interaction
|
||||
if ($(this).is("a[href='#']")){
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
})( jQuery );
|
||||
|
|
|
|||
Loading…
Reference in a new issue