I'm building a single-page application using page.js as the router. The default window.onbeforeunload event doesn't seem to fire when changing pages within the SPA. How can I implement something similar, allowing me to selectively cancel the page transition if the user decides not to proceed? (i.e. "your changes are not saved: ok to discard changes?")
Thanks!