Closed facultymatt closed 10 years ago
It's not possible to change the behavior of onbeforeunload
dialog. Since we don't want to have the reload dialog native but have the unsaved custom, lets shelf this for now.
Might be useful if we later decide to make reload optional, and then are only doing on page navigate where a custom dialog makes more sense.
I just started implementing this on a fork. If you're still interested in this feature let me know and we can coordinate how you envisioned it working. My current approach is like this
~line 225
if(unsavedWarningsConfig.onNavigate){
unsavedWarningsConfig.onNavigate(event);
event.preventDefault();
}else{
...current confirm logic
I'm looking at a way to rethrow the event on confirm. I'd like to hear what you were thinking. my onnavigate and easily return a promise and I could rethrow on reject like:
unsavedWarningsConfig.onNavigate(event).then(
null,
function(){broadcast(event) // or whatever I need to do})
FYI here is the update I made to my fork if anyone wants to use it, it depends on ui-router so I'm not going to put in a pull request: https://github.com/cstephe/angular-unsavedChanges/commit/3fdf55e40a057a54a6bce9af4234746b5ac0c55e
If the user doesn't want to use window.confirm, they should be able to provide a custom strategy.
The strategy should be return a deferred promise. It will resolve / reject based on the user confirming or rejecting the alert.