fix for dialog and subpage key url issues with replace state

This commit is contained in:
John Bender 2011-08-26 14:47:22 -07:00
parent 66fb6bba2f
commit b569c1cc8b
2 changed files with 17 additions and 0 deletions

View file

@ -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 ) {

View file

@ -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 );
}