From b569c1cc8b53c4ceb3b49105d25dd655c5390a36 Mon Sep 17 00:00:00 2001 From: John Bender Date: Fri, 26 Aug 2011 14:47:22 -0700 Subject: [PATCH] fix for dialog and subpage key url issues with replace state --- js/jquery.mobile.navigation.js | 2 ++ js/jquery.mobile.navigation.pushstate.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 2ea773df..eedc1c3f 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -512,6 +512,8 @@ //history stack $.mobile.urlHistory = urlHistory; + $.mobile.dialogHashKey = dialogHashKey; + //default non-animation transition handler $.mobile.noneTransitionHandler = function( name, reverse, $toPage, $fromPage ) { if ( $fromPage ) { diff --git a/js/jquery.mobile.navigation.pushstate.js b/js/jquery.mobile.navigation.pushstate.js index 10c0a2ca..a1b32102 100644 --- a/js/jquery.mobile.navigation.pushstate.js +++ b/js/jquery.mobile.navigation.pushstate.js @@ -34,6 +34,19 @@ }; }, + resetUIState: function( url ) { + var dialog = $.mobile.dialogHashKey, + subkey = "&" + $.mobile.subPageUrlKey; + + if( url.indexOf( dialog ) > -1 ) { + url = url.split( dialog ).join( "#" + dialog ); + } else if( url.indexOf( subkey ) > -1 ) { + url = url.split( subkey ).join( "#" + subkey ); + } + + return url; + }, + // on hash change we want to clean up the url // NOTE this takes place *after* the vanilla navigation hash change // handling has taken place and set the state of the DOM @@ -51,6 +64,8 @@ // make the hash abolute with the current href href = $.mobile.path.makeUrlAbsolute( state.hash.replace("#", ""), location.href ); + href = self.resetUIState( href ); + // replace the current url with the new href and store the state history.replaceState( state, document.title, href ); }