From 722ed2cbbfe9f2bcdfd6420e5ca21f890d51ae3f Mon Sep 17 00:00:00 2001 From: scottjehl Date: Fri, 17 Jun 2011 18:33:16 -0400 Subject: [PATCH] If ajax is disabled, exit the click handler early and avoid parsing the href at all. Thanks for the idea, @toddparker! Fixes #1846. --- js/jquery.mobile.navigation.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 0bb6cd49..a3926d81 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -960,14 +960,25 @@ return; } - var $link = $( link ); + var $link = $( link ), + //remove active link class if external (then it won't be there if you come back) + httpCleanup = function(){ + window.setTimeout( function() { removeActiveLinkClass( true ); }, 200 ); + }; //if there's a data-rel=back attr, go back in history if( $link.is( ":jqmData(rel='back')" ) ) { window.history.back(); return false; } - + + //if ajax is disabled, exit early + if( !$.mobile.ajaxEnabled ){ + httpCleanup(); + //use default click handling + return; + } + var baseUrl = getClosestBaseUrl( $link ), //get href, if defined, otherwise default to empty hash @@ -1016,10 +1027,8 @@ $activeClickedLink = $link.closest( ".ui-btn" ); - if( isExternal || !$.mobile.ajaxEnabled ) { - //remove active link class if external (then it won't be there if you come back) - window.setTimeout( function() { removeActiveLinkClass( true ); }, 200 ); - + if( isExternal ) { + httpCleanup(); //use default click handling return; }