0

I'm trying to prevent any additional dialogs without needing the additional dialog box to be checked. I'm implementing an autosave feature that is called right before the user closes or refreshes the page, so the "changes you made may not be saved" pop-up is unnecessary. I looked at beforeunload and had no luck.

window.onbeforeunload = null;

$(window).on('unload', function (e) {
    $page.model.save(true, function (success) {});
});
  • Can you elaborate on how your code "doesn't work"? What were you expecting, and what actually happened? If you got an exception/error, post the line it occurred on and the exception/error details. Please [edit] these details in or we may not be able to help. – Claudia May 04 '18 at 20:42
  • @IsiahMeadows updated my question, thanks! – Claire Freehafer May 04 '18 at 20:54

1 Answers1

0

Maybe try, instead of just calling

window.onbeforeunload = null; 

Instead use:

$(window).on('beforeunload', function () {
 window.onbeforeunload = null;
});
GeneralBear
  • 1,011
  • 3
  • 11
  • 35