diff --git a/shared/3-sugar/ajax/ajax.js b/shared/3-sugar/ajax/ajax.js index 85d87ff..12a7623 100644 --- a/shared/3-sugar/ajax/ajax.js +++ b/shared/3-sugar/ajax/ajax.js @@ -56,10 +56,10 @@ // Just scroll to the top/element if the link points to the current page // In this case, we also don't want to reload, so we return true - if(target.pathname === window.location.pathname) { + if(mode === 'normal' && target.pathname === window.location.pathname) { var element; if(target.hash) { - if(mode === 'normal' && target.hash !== '#top') { + if(target.hash !== '#top') { history.pushState({}, document.title, target.href); } element = document.getElementById(target.hash.substr(1)); @@ -162,6 +162,9 @@ if(app.go(link)) e.preventDefault(); }); + // Replace the state for the normal page load + history.replaceState({}, document.title, window.location.href); + // Listen on the popstate event on window window.addEventListener('popstate', function(e) { if(e.state !== null) app.go(window.location.href, 'popstate');