Permalink
Browse files

Merge pull request #56 from mkeblx/hash-change

Force reload on hash change
  • Loading branch information...
2 parents cd84010 + 005610d commit b7a0479801abbd31e980250c7221c2987bdeda06 @robhawkes robhawkes committed Feb 28, 2014
Showing with 14 additions and 2 deletions.
  1. +9 −2 src/client/City.js
  2. +5 −0 src/client/DOMEvents.js
View
@@ -44,6 +44,8 @@
this.loop = undefined;
this.publish("addToDat", this, {name: "City", properties: ["init"]});
+
+ this.subscribe("hashchange", this.onHashchange);
};
VIZI.City.prototype.init = function(options) {
@@ -62,8 +64,8 @@
var hash = window.location.hash.replace('#', '');
var coordCheck = /^(\-?\d+(\.\d+)?),(\-?\d+(\.\d+)?)$/;
- if (coordCheck.test(hash) && !_.has(options, 'coords')) {
- options.coords = hash.split(',');
+ if (coordCheck.test(hash)) {
+ options.coords = hash.split(',').reverse();
}
_.defaults(options, {
@@ -283,4 +285,9 @@
// return deferred.promise;
return Q.fcall(function() {});
};
+
+ VIZI.City.prototype.onHashchange = function(){
+ window.location.reload();
+ };
+
}());
View
@@ -19,6 +19,11 @@
self.publish("resize", event);
}, false );
+ // Hash change
+ window.addEventListener( "hashchange", function(event) {
+ self.publish("hashchange", event);
+ }, false );
+
return Q.fcall(function() {});
};
}());

0 comments on commit b7a0479

Please sign in to comment.