From 657f6b8c3f1a78a7488e3a920e4798aa38740415 Mon Sep 17 00:00:00 2001 From: John Bender Date: Tue, 23 Aug 2011 12:07:52 -0700 Subject: [PATCH] make sure the popstate replacestate call uses the full href --- js/jquery.mobile.navigation.pushstate.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js/jquery.mobile.navigation.pushstate.js b/js/jquery.mobile.navigation.pushstate.js index 19cd8dc4..ea82e17f 100644 --- a/js/jquery.mobile.navigation.pushstate.js +++ b/js/jquery.mobile.navigation.pushstate.js @@ -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;