submit() always updates all fields.

submit() always updates all fields.

lhowelllhowell Posts: 2Questions: 0Answers: 0

Hello

I have three buttons "Cancel", "Apply" and "Submit" to match our current systems UX experience. The "Apply" saves the data without closing the form.

So, for submit, I use the this.submit() function. The form has 12 fields. If I change 1 field and the click on "Apply" or "Submit" button, the Ajax post updates all the fields, not just the 1 that was changed.

I know you can add the option "changed" to this function .submit: 'changed', but I do not know how to perform this with the "this.submit()". Any help would be great. First time posting for help.

Thanks

$('#kt_edit').on( 'click', function (e) {
    e.preventDefault();
    editor
        .title( 'Edit User '+userId )
        .buttons( [
            {
                text: 'Cancel',
                className: 'btn btn-primary btn-primary--icon editor_buttons',
                action: function () {
                    this.close();
                }
            },
            {
                text: 'Apply',
                className: 'btn btn-primary btn-primary--icon editor_buttons',
                action: function () {
                    this.submit();
                }
            },
            {
                text: 'Submit',
                className: 'btn btn-primary btn-primary--icon editor_buttons',
                action: function () {
                    this.submit();
                    this.close();
                }
            }
        ] )
        .edit(userTable.rows( { selected: true } ).indexes(),{
            onComplete: 'none'
        } );
} );

Replies

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    You would add that changed to the edit(), something like this:

            .edit(userTable.rows( { selected: true } ).indexes(),{
                onComplete: 'none',
                submit: 'changed'
            } );
    

    When submit() is called, it would use those form-options from when edit() was called.

    Colin

  • lhowelllhowell Posts: 2Questions: 0Answers: 0

    That solved the problem. Thanks so much.

Sign In or Register to comment.