mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-10 09:21:02 +00:00
Switch back to hijacking links on the click event. We'll focus on improving "percieved" visual performance since launching a page load and transitions on vclick opens us up to too many problems:
- Third party click handlers never called. - Touch and click target mismatches due markup changes before the click events are generated. (What looks like a double click event)
This commit is contained in:
parent
5c37beaa29
commit
d43bbfc52a
1 changed files with 4 additions and 28 deletions
|
|
@ -687,11 +687,8 @@
|
|||
});
|
||||
|
||||
|
||||
//temporary fix for allowing 3rd party onclick handlers to still function.
|
||||
var preventClickDefault = false, stopClickPropagation = false;
|
||||
|
||||
//click routing - direct to HTTP or Ajax, accordingly
|
||||
$( "a" ).live( "vclick", function(event) {
|
||||
$( "a" ).live( "click", function(event) {
|
||||
|
||||
var $this = $(this),
|
||||
|
||||
|
|
@ -732,27 +729,17 @@
|
|||
//if data-ajax attr is set to false, use the default behavior of a link
|
||||
hasAjaxDisabled = $this.is( ":jqmData(ajax='false')" );
|
||||
|
||||
//reset our prevDefault value because I'm paranoid.
|
||||
preventClickDefault = stopClickPropagation = false;
|
||||
|
||||
//if there's a data-rel=back attr, go back in history
|
||||
if( $this.is( ":jqmData(rel='back')" ) ){
|
||||
window.history.back();
|
||||
preventClickDefault = stopClickPropagation = true;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
//prevent # urls from bubbling
|
||||
//path.get() is replaced to combat abs url prefixing in IE
|
||||
if( url.replace(path.get(), "") == "#" ){
|
||||
//for links created purely for interaction - ignore
|
||||
//don't call preventDefault on the event here, vclick
|
||||
//may have been triggered by a touchend, before any moues
|
||||
//click event was dispatched and we want to make sure
|
||||
//3rd party onclick handlers get triggered. If and when
|
||||
//a mouse click event is generated, our live("click") handler
|
||||
//will get triggered and do the preventDefault.
|
||||
preventClickDefault = true;
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -786,18 +773,7 @@
|
|||
url = path.stripHash( url );
|
||||
|
||||
$.mobile.changePage( url, transition, reverse);
|
||||
preventClickDefault = true;
|
||||
});
|
||||
|
||||
$( "a" ).live( "click", function(event) {
|
||||
if (preventClickDefault){
|
||||
event.preventDefault();
|
||||
preventClickDefault = false;
|
||||
}
|
||||
if (stopClickPropagation){
|
||||
event.stopPropagation();
|
||||
stopClickPropagation = false;
|
||||
}
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
//hashchange event handler
|
||||
|
|
|
|||
Loading…
Reference in a new issue