don't allow close of editor
don't allow close of editor
I don't want to allow users to close the editor by clicking the background (grey area) or the 'x' in the upper right of the editor window. I think the answer is somewhere in this code: https://editor.datatables.net/examples/api/confirmClose.html
but of course there would be no blur if they don't make any changes.
var PasswordChangeEditor = new $.fn.dataTable.Editor({
ajax: 'api/Staff',
table: '#passChange',
fields: [
{ label: "New Password", name: "Password" }
]
});
PasswordChangeEditor.add([
{
label: "Type password again:",
name: "confirmPassword"
}
]);
var PasswordChangeTable = $('#passChange').DataTable({
ajax: 'api/Staff',
columns: [
{ data: "Password" }
]
});
PasswordChangeEditor.on('preSubmit', function (e, data, action) {
var password = PasswordChangeEditor.get('Password');
var password2 = PasswordChangeEditor.get('confirmPassword');
if (password != password2) {
alert("Passwords don't match. Please re-type the password.");
return false;
} else {
$.ajax({
url: "api/ChangePass?login=" + userNameCookie + '&isReset=0&password=' + password,
async: false,
type: "POST",
data: data
});
PasswordChangeEditor.close();
return false;
}
});
I open the editor after an ajax call
if (response.Table[0].PasswordReset == 1) {
PasswordChangeEditor
.create()
.title('Change Password')
.display(true)
.buttons('Save')
;
}
This discussion has been closed.
Answers
This thread should help, it's asking the same thing.
Cheers,
Colin
almost there. thank you for that.
now, how do you get rid of the 'x' at the top right of the editor (just on this editor, not all editors in my project)? I looked here but didn't see anything: https://editor.datatables.net/reference/option/
A quick "Inspect" will show that the element has a class of
DTED_Lightbox_Close
. You can use a little CSS to set that to bedisplay: none;
.Allan
ah, ok. thanks. I wasn't sure if there was something in the Editor initialization where you could turn that off.