Add event to form to confirm open changes

This commit is contained in:
bergware
2021-06-04 20:13:18 +02:00
parent bbd59b1630
commit 55faf170a5
@@ -688,11 +688,7 @@ $(function() {
form.find('input[value="<?=_("Done")?>"],input[value="Done"]').not('input.lock').val("<?=_('Reset')?>").prop('onclick',null).off('click').click(function(){formHasUnsavedChanges=false;refresh(form.offset().top);});
});});
// add leave confirmation when form has changed without applying (opt-in function)
$('form.js-confirm-leave').on('change',function(e){
formHasUnsavedChanges=true;
}).on('submit',function(e){
formHasUnsavedChanges=false;
});
$('form.js-confirm-leave').on('change',function(e){formHasUnsavedChanges=true;}).on('submit',function(e){formHasUnsavedChanges=false;});
$(window).on('beforeunload',function(e){if (formHasUnsavedChanges) return '';}); // note: the browser creates its own popup window and warning message
var top = ($.cookie('top')||0) - $('.tabs').offset().top - 75;