mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-19 20:01:52 +00:00
make sure the popstate replacestate call uses the full href
This commit is contained in:
parent
2c7789b6a3
commit
657f6b8c3f
1 changed files with 8 additions and 5 deletions
|
|
@ -11,16 +11,17 @@
|
|||
var pushStateHandler = {},
|
||||
self = pushStateHandler,
|
||||
oldRegisterInternalEvents = $.mobile._registerInternalEvents,
|
||||
$win = $( window );
|
||||
$win = $( window ),
|
||||
url = $.mobile.path.parseUrl( location.href );
|
||||
|
||||
$.extend( pushStateHandler, {
|
||||
// TODO move to a path helper, this is rather common functionality
|
||||
initialFilePath: (function() {
|
||||
var url = $.mobile.path.parseUrl( location.href );
|
||||
|
||||
return url.pathname + url.search;
|
||||
})(),
|
||||
|
||||
initialHref: url.hrefNoHash,
|
||||
|
||||
// Begin with popstate listening disabled, since it fires at onload in chrome
|
||||
popListeningEnabled: false,
|
||||
|
||||
|
|
@ -31,7 +32,9 @@
|
|||
return {
|
||||
hash: location.hash || "#" + self.initialFilePath,
|
||||
title: document.title,
|
||||
originalHref: self.initialFilePath
|
||||
|
||||
// persiste across refresh
|
||||
initialHref: self.initialHref
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -58,7 +61,7 @@
|
|||
onPopState: function( e ) {
|
||||
var poppedState = e.originalEvent.state;
|
||||
if( self.popListeningEnabled && poppedState ) {
|
||||
history.replaceState( poppedState, poppedState.title, poppedState.originalHref + poppedState.hash );
|
||||
history.replaceState( poppedState, poppedState.title, poppedState.initialHref + poppedState.hash );
|
||||
|
||||
// Urls that reference subpages will fire their own hashchange, so we don't want to trigger 2 in that case.
|
||||
self.hashchangeFired = false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue