mirror of
https://github.com/vrana/adminer.git
synced 2025-08-09 08:06:59 +02:00
Confirm before exiting edited edit form
This commit is contained in:
@@ -575,6 +575,29 @@ function fieldChange() {
|
||||
|
||||
|
||||
|
||||
let editChanged;
|
||||
|
||||
/** Setup saving editChanged on form fields
|
||||
* @this HTMLFormElement
|
||||
*/
|
||||
function setupEditChange(form) {
|
||||
for (const el of qsa('input, select, textarea', form)) {
|
||||
el.addEventListener('change', () => {
|
||||
editChanged = true;
|
||||
});
|
||||
}
|
||||
form.onsubmit = () => {
|
||||
editChanged = null; // false doesn't work in Chrome
|
||||
}
|
||||
}
|
||||
|
||||
onbeforeunload = () => {
|
||||
// all modern browsers ignore string returned from here
|
||||
return editChanged;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Create AJAX request
|
||||
* @param string
|
||||
* @param function (XMLHttpRequest)
|
||||
|
Reference in New Issue
Block a user