Quantcast
Channel: Editor — DataTables forums
Viewing all articles
Browse latest Browse all 3744

don't allow close of editor

$
0
0

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')
                                ;
                            }

Viewing all articles
Browse latest Browse all 3744

Trending Articles