Last active
December 11, 2015 09:48
-
-
Save gabrielschulhof/4581892 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/js/jquery.mobile.navigation.js b/js/jquery.mobile.navigation.js | |
index 775b8a1..d9ce832 100644 | |
--- a/js/jquery.mobile.navigation.js | |
+++ b/js/jquery.mobile.navigation.js | |
@@ -884,7 +884,7 @@ define( [ | |
} | |
// Set the location hash. | |
- if ( settings.changeHash !== false && url ) { | |
+ if ( url ) { | |
// rebuilding the hash here since we loose it earlier on | |
// TODO preserve the originally passed in path | |
if( !path.isPath( url ) && url.indexOf( "#" ) < 0 ) { | |
@@ -897,7 +897,7 @@ define( [ | |
title: pageTitle, | |
pageUrl: pageUrl, | |
role: settings.role | |
- }, true); | |
+ }, true, !( settings.changeHash ) ); | |
} | |
//set page title | |
diff --git a/js/navigation/method.js b/js/navigation/method.js | |
index 74c96b7..c35d943 100644 | |
--- a/js/navigation/method.js | |
+++ b/js/navigation/method.js | |
@@ -9,8 +9,8 @@ define([ "jquery", "./path", "./history", "./navigator" ], function( jQuery ) { | |
// TODO consider queueing navigation activity until previous activities have completed | |
// so that end users don't have to think about it. Punting for now | |
// TODO !! move the event bindings into callbacks on the navigate event | |
- $.mobile.navigate = function( url, data, noEvents ) { | |
- $.mobile.navigate.navigator.go( url, data, noEvents ); | |
+ $.mobile.navigate = function( url, data, noEvents, noHashWrite ) { | |
+ $.mobile.navigate.navigator.go( url, data, noEvents, noHashWrite ); | |
}; | |
// expose the history on the navigate method in anticipation of full integration with | |
diff --git a/js/navigation/navigator.js b/js/navigation/navigator.js | |
index 2ce7d40..fc58d01 100644 | |
--- a/js/navigation/navigator.js | |
+++ b/js/navigation/navigator.js | |
@@ -82,7 +82,7 @@ define(["jquery", | |
}, | |
// TODO reconsider name | |
- go: function( url, data, noEvents ) { | |
+ go: function( url, data, noEvents, noHashWrite ) { | |
var state, href, hash, popstateEvent, | |
isPopStateEvent = $.event.special.navigate.isPushStateEnabled(); | |
@@ -96,7 +96,7 @@ define(["jquery", | |
// history management. In the case of hashchange we don't swallow it | |
// if there will be no hashchange fired (since that won't reset the value) | |
// and will swallow the following hashchange | |
- if( noEvents && hash !== path.stripHash(path.parseLocation().hash) ) { | |
+ if( !noHashWrite && noEvents && hash !== path.stripHash(path.parseLocation().hash) ) { | |
this.preventNextHashChange = noEvents; | |
} | |
@@ -110,8 +110,9 @@ define(["jquery", | |
// | |
// if the url is a path we want to preserve the query params that are available on | |
// the current url. | |
- this.preventHashAssignPopState = true; | |
- window.location.hash = hash; | |
+ if ( !noHashWrite ) { | |
+ this.preventHashAssignPopState = true; | |
+ window.location.hash = hash; | |
// If popstate is enabled and the browser triggers `popstate` events when the hash | |
// is set (this often happens immediately in browsers like Chrome), then the | |
@@ -119,7 +120,8 @@ define(["jquery", | |
// a `popstate` on hash assignement or `replaceState` then we need avoid the branch | |
// that swallows the event created by the popstate generated by the hash assignment | |
// At the time of this writing this happens with Opera 12 and some version of IE | |
- this.preventHashAssignPopState = false; | |
+ this.preventHashAssignPopState = false; | |
+ } | |
state = $.extend({ | |
url: href, | |
@@ -127,7 +129,7 @@ define(["jquery", | |
title: document.title | |
}, data); | |
- if( isPopStateEvent ) { | |
+ if( !noHashWrite && isPopStateEvent ) { | |
popstateEvent = new $.Event( "popstate" ); | |
popstateEvent.originalEvent = { | |
type: "popstate", |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment