public
Last active

  • Download Gist
gistfile1.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
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",

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.