Commit d71b5167fd8ae8a29f35426f37137af390e8b912
1 parent
dcc55bea
Almost functionning dynamic nav history
Showing
1 changed file
with
8 additions
and
1 deletions
Show diff stats
js/crep.js
@@ -20,7 +20,9 @@ function loadDoc(location) { | @@ -20,7 +20,9 @@ function loadDoc(location) { | ||
20 | $.get(location + '?c', function (data) { | 20 | $.get(location + '?c', function (data) { |
21 | mainContainer = $("#mainContainer") | 21 | mainContainer = $("#mainContainer") |
22 | mainContainer.html(data) | 22 | mainContainer.html(data) |
23 | - history.pushState({}, document.title, location) | 23 | + history.pushState({ |
24 | + loc: location | ||
25 | + }, document.title, location) | ||
24 | // POST | 26 | // POST |
25 | dynamiseLinks(mainContainer) | 27 | dynamiseLinks(mainContainer) |
26 | pageSpecific(location) | 28 | pageSpecific(location) |
@@ -28,9 +30,14 @@ function loadDoc(location) { | @@ -28,9 +30,14 @@ function loadDoc(location) { | ||
28 | 30 | ||
29 | } | 31 | } |
30 | 32 | ||
33 | +function historyChange(ev) { | ||
34 | + loadDoc(ev.state.loc) | ||
35 | +} | ||
36 | + | ||
31 | $(document).ready(function () { | 37 | $(document).ready(function () { |
32 | dynamiseLinks(document) | 38 | dynamiseLinks(document) |
33 | pageSpecific(window.location.href) | 39 | pageSpecific(window.location.href) |
40 | + window.onpopstate = historyChange | ||
34 | }) | 41 | }) |
35 | 42 | ||
36 | function initializeMap() { | 43 | function initializeMap() { |