Skip to content

Commit a3487e6

Browse files
committed
simplified the default hash handling prevention back to somthing akin to @scottjehl's original implementation
1 parent 76d5c49 commit a3487e6

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

js/jquery.mobile.navigation.pushstate.js

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@
3434
};
3535
},
3636

37-
isSubHashPage: function( page ) {
38-
var pageUrl = page.jqmData("url") || "";
39-
40-
// if the page is a dialog, a subpage, or an embedded page
41-
// then the hash will have been maintained
42-
return page.is( "[role='dialog']" ) ||
43-
pageUrl.indexOf( $.mobile.subPageUrlKey ) >= 0 ||
44-
pageUrl === page.attr( "id" );
45-
},
46-
4737
resetUIKeys: function( url ) {
4838
var dialog = $.mobile.dialogHashKey,
4939
subkey = "&" + $.mobile.subPageUrlKey,
@@ -90,18 +80,18 @@
9080
// if there's no state its not a popstate we care about, ie chrome's initial popstate
9181
// or forward popstate
9282
if( poppedState ) {
93-
// can't test the hash directly because the url has already been altered, possibly to
94-
// one without a hash, so we check if the page on display is one that would have
95-
// generated a hash. Generally speaking a crappy solution.
96-
if( self.isSubHashPage( $.mobile.activePage ) ){
97-
holdnexthashchange = true;
98-
}
99-
100-
// change the page based on the hash
101-
$.mobile._handleHashChange( poppedState.hash );
102-
103-
// disable the next hash change if the page we came from has a hash
104-
$.mobile.urlHistory.ignoreNextHashChange = holdnexthashchange;
83+
// disable any hashchange triggered by the browser
84+
$.mobile.urlHistory.ignoreNextHashChange = true;
85+
86+
// defer our manual hashchange until after the browser fired
87+
// version has come and gone
88+
setTimeout(function() {
89+
// make sure that the manual hash handling takes place
90+
$.mobile.urlHistory.ignoreNextHashChange = false;
91+
92+
// change the page based on the hash
93+
$.mobile._handleHashChange( poppedState.hash );
94+
});
10595
}
10696
},
10797

0 commit comments

Comments
 (0)