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:
Kin Blas 2011-03-31 09:19:05 -07:00
parent 14fbe8b164
commit 3ce228e3f2

View file

@ -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 );