I've a form in a pop-up, which is loaded by AJAX call. It is built using form_for
tag of RoR. Even if I don't modify any field in it and try to navigate to another page, following alert is shown by chrome.
I want to disable this alert box. Is it possible? If yes, how?
I've already tried this, but it is not valid anymore.
Following are the environment settings,
Ruby version = 1.9.3
Rails version = 3.1.4
Chrome version = 52
jQuery version = 1.10.2
Alert is displayed because somewhere on your code, you are overriding the window before unload event, and when you try to close the window, the event fires. Try disallow this event putting up this on your code:
window.onbeforeunload = null;
You can hook in any other function inside the beforeunload
handler:
window.addEventListener("beforeunload", function(e){
yourCustomFunction();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With