From d6489a758b79713c1c79b67991c7b97f5111401e Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Mon, 2 Mar 2015 16:50:13 +0100 Subject: [PATCH] History working with dynamic nav --- js/crep.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/js/crep.js b/js/crep.js index 6d6dd3b..31158c6 100755 --- a/js/crep.js +++ b/js/crep.js @@ -7,7 +7,11 @@ function pageSpecific(location) { function actLink(ev) { var location = ev.currentTarget.href if (location.indexOf(window.location.host) >= 0) { - loadDoc(location) + loadDoc(location, function () { + history.pushState({ + loc: location + }, document.title, location) + }) return false } } @@ -16,16 +20,19 @@ function dynamiseLinks(el) { $("a", el).click(actLink) } -function loadDoc(location) { +function loadDoc(location, callback)) { + if (!callback) { + callaback = function () { + return undefined + } + } $.get(location + '?c', function (data) { mainContainer = $("#mainContainer") mainContainer.html(data) - history.pushState({ - loc: location - }, document.title, location) - // POST + document.title = location dynamiseLinks(mainContainer) pageSpecific(location) + callback() }) } -- libgit2 0.21.2