Versions:
jQuery 3.2.1
DataTables 1.10.16
Editor 1.6.5
I'm trying to create a prompt that asks people if they intended to delete a record if Deleted is selected from a status dropdown box (delete is actually updating a status column in the database, not an actual SQL delete). I've been trying to get it to work consistently, but I keep running into preSubmit firing twice.
I have the following code as a test:
editor.on( 'preSubmit', function ( e, data, action ) {
alert('test');
return false;
});
Whenever I submit the form, it alerts me with "test" twice, no matter what. If I add conditional code inside to check for if it's Deleted as in the following code:
// make sure user intended to delete record
editor.on( 'preSubmit', function ( e, data, action ) {
if(editor.field( '__my status field__' ).input().val() == '5'){
if(!confirm('Are you sure you want to delete this record?')){
return false;
}else{
return true;
};
}
});
It'll pop up asking me the question. If I hit "cancel", it'll ask me again. If I hit cancel again, it'll submit the form the next time I try to submit.
I'm stumped, and I'm hoping it's not a typo like last time you helped me (I seriously checked for that, I swear hah).