Closed itay-grudev closed 8 years ago
This is intended, because popstate
events are not preventable (unlike normal visits). Also, when the popstate
event fires, the URL has already changed, so firing page:before-change
at that time would lead to inconsistent behavior.
What are you using the event for?
I needed to update something if the user goes back. You could create an event that is invoked in both cases, and explicitly state that it can't be prevented and document the inconsistencies. It would still be useful.
Have you tried using page:before-unload
? It fires before the page changes (including on partial replacement).
I tried many solutions and I ultimately gave up. I did tried before-unload
, but as far as I remember it wasn't invoked on going back or it reported wrong URL. I don't really remember, but it didn't do the job.
It is invoked on history back/forward. What URL did you expect it to report? How are you reading the URL?
I ultimately used a variable to store the previous page loaded and I bypassed the problem. Thank you for your time and will to help, but this was a month ago and I really don't remember.
According to your documentation the
page:before-change
event should be triggered when restoring a page (going back for example), but that is not the case.