From a3487e620d433f4e4e7126a3be2bf2af2253da4d Mon Sep 17 00:00:00 2001 From: John Bender Date: Sat, 27 Aug 2011 02:47:54 -0700 Subject: [PATCH] simplified the default hash handling prevention back to somthing akin to @scottjehl's original implementation --- js/jquery.mobile.navigation.pushstate.js | 32 ++++++++---------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/js/jquery.mobile.navigation.pushstate.js b/js/jquery.mobile.navigation.pushstate.js index 947f93a3..06bd748a 100644 --- a/js/jquery.mobile.navigation.pushstate.js +++ b/js/jquery.mobile.navigation.pushstate.js @@ -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 ) { var dialog = $.mobile.dialogHashKey, subkey = "&" + $.mobile.subPageUrlKey, @@ -90,18 +80,18 @@ // if there's no state its not a popstate we care about, ie chrome's initial popstate // or forward popstate if( poppedState ) { - // can't test the hash directly because the url has already been altered, possibly to - // one without a hash, so we check if the page on display is one that would have - // generated a hash. Generally speaking a crappy solution. - if( self.isSubHashPage( $.mobile.activePage ) ){ - holdnexthashchange = true; - } + // disable any hashchange triggered by the browser + $.mobile.urlHistory.ignoreNextHashChange = true; - // change the page based on the hash - $.mobile._handleHashChange( poppedState.hash ); - - // disable the next hash change if the page we came from has a hash - $.mobile.urlHistory.ignoreNextHashChange = holdnexthashchange; + // defer our manual hashchange until after the browser fired + // version has come and gone + setTimeout(function() { + // make sure that the manual hash handling takes place + $.mobile.urlHistory.ignoreNextHashChange = false; + + // change the page based on the hash + $.mobile._handleHashChange( poppedState.hash ); + }); } },