Skip to content

Commit

Permalink
Merge pull request #56 from mkeblx/hash-change
Browse files Browse the repository at this point in the history
Force reload on hash change
  • Loading branch information
robhawkes committed Feb 28, 2014
2 parents cd84010 + 005610d commit b7a0479
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/client/City.js
Expand Up @@ -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) {
Expand All @@ -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, {
Expand Down Expand Up @@ -283,4 +285,9 @@
// return deferred.promise;
return Q.fcall(function() {});
};

VIZI.City.prototype.onHashchange = function(){
window.location.reload();
};

}());
5 changes: 5 additions & 0 deletions src/client/DOMEvents.js
Expand Up @@ -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.