Skip to content

Commit 722ed2c

Browse files
author
scottjehl
committed
If ajax is disabled, exit the click handler early and avoid parsing the href at all. Thanks for the idea, @toddparker! Fixes jquery-archive#1846.
1 parent b3aa565 commit 722ed2c

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

js/jquery.mobile.navigation.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -960,14 +960,25 @@
960960
return;
961961
}
962962

963-
var $link = $( link );
963+
var $link = $( link ),
964+
//remove active link class if external (then it won't be there if you come back)
965+
httpCleanup = function(){
966+
window.setTimeout( function() { removeActiveLinkClass( true ); }, 200 );
967+
};
964968

965969
//if there's a data-rel=back attr, go back in history
966970
if( $link.is( ":jqmData(rel='back')" ) ) {
967971
window.history.back();
968972
return false;
969973
}
970-
974+
975+
//if ajax is disabled, exit early
976+
if( !$.mobile.ajaxEnabled ){
977+
httpCleanup();
978+
//use default click handling
979+
return;
980+
}
981+
971982
var baseUrl = getClosestBaseUrl( $link ),
972983

973984
//get href, if defined, otherwise default to empty hash
@@ -1016,10 +1027,8 @@
10161027

10171028
$activeClickedLink = $link.closest( ".ui-btn" );
10181029

1019-
if( isExternal || !$.mobile.ajaxEnabled ) {
1020-
//remove active link class if external (then it won't be there if you come back)
1021-
window.setTimeout( function() { removeActiveLinkClass( true ); }, 200 );
1022-
1030+
if( isExternal ) {
1031+
httpCleanup();
10231032
//use default click handling
10241033
return;
10251034
}

0 commit comments

Comments
 (0)