From d43bbfc52afc9c03284293db1053cc6abc5f557f Mon Sep 17 00:00:00 2001 From: Kin Blas Date: Mon, 4 Apr 2011 10:00:24 -0700 Subject: [PATCH] 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) --- js/jquery.mobile.navigation.js | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 5fc74b61..8a36beaa 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -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