Sharing is caring. I find it helpful to provide a warning with opt out when the user attempts to close an edit popup with unsaved changes and don't see that functionality included by Xlinesoft. I attain that capabiity by adding the following canned javascript to my Edit Page OnPageLoad events.
var formChanged = false;
// Detect any changes in form controls
$("input").on('change', function() { formChanged = true; });
$("select").on('change', function() { formChanged = true; });
$("textarea").on('change', function() { formChanged = true; });
// Reset flag when saving
pageObj.on('beforeSave', function() {
formChanged = false;
return true;
});
// Intercept close/cancel actions
$('.modal-header .close, [id^="closeButton"]').on('click', function(e) {
if (formChanged) {
if (!confirm("You have unsaved changes. Are you sure you want to close?")) {
e.stopPropagation();
e.preventDefault();
return false;
}
}
});