Ignore hashchange-triggered popstate events here too
This commit is contained in:
parent
b2a82f501d
commit
e68e3e9150
1 changed files with 6 additions and 1 deletions
|
@ -50,7 +50,12 @@ OSM.Router = function(rts) {
|
|||
currentRoute.run('load', currentPath);
|
||||
|
||||
if (window.history && window.history.pushState) {
|
||||
$(window).on('popstate', function() {
|
||||
// Set a non-null initial state, so that the e.originalEvent.state
|
||||
// check below works correctly when going back to the initial page.
|
||||
window.history.replaceState({}, document.title, window.location);
|
||||
|
||||
$(window).on('popstate', function(e) {
|
||||
if (!e.originalEvent.state) return; // Is it a real popstate event or just a hash change?
|
||||
var path = window.location.pathname + window.location.search;
|
||||
if (path === currentPath) return;
|
||||
currentRoute.run('unload');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue