Verified Commit 08b85cfb authored by Markus Koller's avatar Markus Koller 🦊
Browse files

Confirm navigation with unsaved form changes

parent 8e97dc21
$(() => {
let formSubmitting = false, formData = $('form').serialize();
$(window).on('beforeunload', (event) => {
if (!formSubmitting && ($('.has-error').length || formData !== $('form').serialize())) {
event.returnValue = "Möchten Sie Ihre ungespeicherten Änderungen verwerfen?";
return event.returnValue;
}
});
$(document).on('submit', 'form', () => {
formSubmitting = true;
});
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment