question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hello,

Is it possible to latch onto the window.onpopstate event Navigo uses for forward/back buttons? I can use it easily enough, but then navigo stops working 😃

I have a page transition in this project, so it’s not possible to re-render the menu in this case. I’m manually updating the .active class on the menu with jQuery, which works fine, except for the forward/back browser buttons.

Was thinking a custom event could be fired onpopstate with the window.location.pathname passed to it, but interested in your thoughts.

Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
daviestarcommented, Jul 17, 2016

Oh yes, of course. D’oh!

Thanks again.

0reactions
krasimircommented, Jul 17, 2016

This will pollute your route handlers but can be solved with partial execution (or currying).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Window: popstate event - Web APIs | MDN
The popstate event of the Window interface is fired when the active history entry changes while the user navigates the session history.
Read more >
Handling window.onpopstate events - Learn ECMAScript
The window.onpopstate event is fired automatically by the browser when a user navigates between history states that a developer has set.
Read more >
window.onpopstate is not working; nothing happens when I ...
You get a popstate event only if you add one or more history entry/entries and later the user clicks the back button in...
Read more >
JavaScript popstate Event - The Simplest Explanation
The popstate event fires whenever the browser is navigated to a page with the same document object as the current page. Note that...
Read more >
The PopStateEvent - W3Schools
Event Types. These event types belongs to the PopStateEvent Object: Event, Description. popstate, The event occurs when the window's history changes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found