diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js index 7748fb76ece..e3721957a08 100644 --- a/js/jquery.mobile.navigation.js +++ b/js/jquery.mobile.navigation.js @@ -875,14 +875,6 @@ define( [ } } - // Set the location hash. - if ( settings.changeHash !== false && url ) { - //disable hash listening temporarily - urlHistory.ignoreNextHashChange = true; - //update hash and history - path.set( url ); - } - // if title element wasn't found, try the page div data attr too // If this is a deep-link or a reload ( active === undefined ) then just use pageTitle var newPageTitle = ( !active )? pageTitle : toPage.jqmData( "title" ) || toPage.children( ":jqmData(role='header')" ).find( ".ui-title" ).getEncodedText(); @@ -907,6 +899,14 @@ define( [ urlHistory.addNew( url, settings.transition, pageTitle, pageUrl, settings.role ); } + // Set the location hash. + if ( settings.changeHash !== false && url ) { + //disable hash listening temporarily + urlHistory.ignoreNextHashChange = true; + //update hash and history + path.set( url ); + } + //set page title document.title = urlHistory.getActive().title; diff --git a/js/navigation/navigate.js b/js/navigation/navigate.js index 09ab4c7de98..fd75cd6e6d6 100644 --- a/js/navigation/navigate.js +++ b/js/navigation/navigate.js @@ -112,6 +112,12 @@ define([ return; } + // account for initial page load popstate, and other popstates triggered + // by other parts of the application (ie, during the refactor) + if( !event.originalEvent.state ) { + return; + } + // If this is a popstate that comes from the back or forward buttons // make sure to set the state of our history stack properly history.direct({