Permalink
Browse files

Add hashchange listener to support back/forward buttons

  • Loading branch information...
1 parent 438ec79 commit 7eb3ce74f68f6bb5af9940ff78969e501d806f1d @davidaurelio davidaurelio committed Nov 21, 2013
Showing with 8 additions and 3 deletions.
  1. +8 −3 example/library/index.html
@@ -141,16 +141,21 @@
viewModel.selected.movie(movieSelect.value);
};
- // parse initial values from url hash
- (function(query) {
+ function parseQuery(query) {
var values = viewModel.selected;
var bit, key, bits = query.split('&');
for (var i = 0, n = bits.length; i < n; i++) {
bit = bits[i].split('=');
key = decodeURIComponent(bit[0]);
if (key in values) values[key](decodeURIComponent(bit[1]));
}
- }(location.hash.slice(2)));
+ }
+
+ // parse initial values from url hash
+ window.onhashchange = function() {
+ parseQuery(location.hash.slice(2));
+ };
+ window.onhashchange();
require.config({
baseUrl: '../../src',

0 comments on commit 7eb3ce7

Please sign in to comment.