You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been finding it rather difficult to prevent a user from leaving a page if they have unsaved changes since onbeforeunload is never called. I'd like to display a confirmation "Are you sure you want to leave? Unsaved changes will be lost" before letting them leave.
One solution could be to add a before-location-changed event that is cancelable in the _updateUrl and _globalOnClick methods just before a state is pushed/replaced.
if (this.fire("before-location-changed",{},{cancelable:true}).defaultPrevented){
return
}
This wouldn't work for back/forward browser navigation and you would still have to fire that event yourself if you wanted to imperatively change the url in the format that is suggested in the docs. If you change the path, query, or hash directly, the event would be called in the _updateUrl, we would just also have to reset those variables if defaultPrevented was true.
Open to other solutions, just figure this is a common issue.
The text was updated successfully, but these errors were encountered:
I've been finding it rather difficult to prevent a user from leaving a page if they have unsaved changes since onbeforeunload is never called. I'd like to display a confirmation "Are you sure you want to leave? Unsaved changes will be lost" before letting them leave.
One solution could be to add a before-location-changed event that is cancelable in the _updateUrl and _globalOnClick methods just before a state is pushed/replaced.
This wouldn't work for back/forward browser navigation and you would still have to fire that event yourself if you wanted to imperatively change the url in the format that is suggested in the docs. If you change the path, query, or hash directly, the event would be called in the _updateUrl, we would just also have to reset those variables if defaultPrevented was true.
Open to other solutions, just figure this is a common issue.
The text was updated successfully, but these errors were encountered: