simplified the default hash handling prevention back to somthing akin to @scottjehl's original implementation

This commit is contained in:
John Bender 2011-08-27 02:47:54 -07:00
parent 76d5c49b78
commit a3487e620d

View file

@ -34,16 +34,6 @@
}; };
}, },
isSubHashPage: function( page ) {
var pageUrl = page.jqmData("url") || "";
// if the page is a dialog, a subpage, or an embedded page
// then the hash will have been maintained
return page.is( "[role='dialog']" ) ||
pageUrl.indexOf( $.mobile.subPageUrlKey ) >= 0 ||
pageUrl === page.attr( "id" );
},
resetUIKeys: function( url ) { resetUIKeys: function( url ) {
var dialog = $.mobile.dialogHashKey, var dialog = $.mobile.dialogHashKey,
subkey = "&" + $.mobile.subPageUrlKey, subkey = "&" + $.mobile.subPageUrlKey,
@ -90,18 +80,18 @@
// if there's no state its not a popstate we care about, ie chrome's initial popstate // if there's no state its not a popstate we care about, ie chrome's initial popstate
// or forward popstate // or forward popstate
if( poppedState ) { if( poppedState ) {
// can't test the hash directly because the url has already been altered, possibly to // disable any hashchange triggered by the browser
// one without a hash, so we check if the page on display is one that would have $.mobile.urlHistory.ignoreNextHashChange = true;
// generated a hash. Generally speaking a crappy solution.
if( self.isSubHashPage( $.mobile.activePage ) ){
holdnexthashchange = true;
}
// change the page based on the hash // defer our manual hashchange until after the browser fired
$.mobile._handleHashChange( poppedState.hash ); // version has come and gone
setTimeout(function() {
// disable the next hash change if the page we came from has a hash // make sure that the manual hash handling takes place
$.mobile.urlHistory.ignoreNextHashChange = holdnexthashchange; $.mobile.urlHistory.ignoreNextHashChange = false;
// change the page based on the hash
$.mobile._handleHashChange( poppedState.hash );
});
} }
}, },