Permalink
Browse files

disable hash based functionality when hashListeningEnabled is false F…

…ixes #5445
  • Loading branch information...
johnbender committed Jan 16, 2013
1 parent d02e044 commit 40fb7d86660042d32c28ab3b008f65ad7915e17e
Showing with 19 additions and 6 deletions.
  1. +11 −2 js/events/navigate.js
  2. +8 −4 js/navigation/navigator.js
View
@@ -17,8 +17,17 @@ define([ "jquery", "./../jquery.mobile.ns", "./../jquery.mobile.support" ], func
originalEventName: undefined,
// If pushstate support is present and push state support is defined to
// be true on the mobile namespace.
isPushStateEnabled: function() {
return $.support.pushState && $.mobile && $.mobile.pushStateEnabled;
return $.support.pushState &&
$.mobile.pushStateEnabled === true &&
this.isHashChangeEnabled();
},
// !! assumes mobile namespace is present
isHashChangeEnabled: function() {
return $.mobile.hashListeningEnabled === true;
},
// TODO a lot of duplication between popstate and hashchange
@@ -92,7 +101,7 @@ define([ "jquery", "./../jquery.mobile.ns", "./../jquery.mobile.support" ], func
if( self.isPushStateEnabled() ) {
self.originalEventName = "popstate";
$win.bind( "popstate.navigate", self.popstate );
} else {
} else if ( self.isHashChangeEnabled() ){
self.originalEventName = "hashchange";
$win.bind( "hashchange.navigate", self.hashchange );
}
View
@@ -239,11 +239,12 @@ define(["jquery",
// TODO add a check here that `hashchange.navigate` is bound already otherwise it's
// broken (exception?)
hashchange: function( event ) {
var history = this.history, hash = path.parseLocation().hash;
var history, hash;
// If pushstate is supported the state will be included in the popstate event
// data and appended to the navigate event. Late check here for late settings (eg tests)
if( $.event.special.navigate.isPushStateEnabled() ) {
// If hashchange listening is explicitly disabled or pushstate is supported
// avoid making use of the hashchange handler.
if(!$.event.special.navigate.isHashChangeEnabled() ||
$.event.special.navigate.isPushStateEnabled() ) {
return;
}
@@ -255,6 +256,9 @@ define(["jquery",
return;
}
history = this.history;
hash = path.parseLocation().hash;
// If this is a hashchange caused by the back or forward button
// make sure to set the state of our history stack properly
this.history.direct({

0 comments on commit 40fb7d8

Please sign in to comment.