1
0
Fork 0

Fix AJAX popstate event

master
Lukas Bestle 9 years ago
parent f9c5f3db5a
commit c8e5bd98cc

@ -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');

Loading…
Cancel
Save