Editor submits boolean fields as changed even when it's not.

Editor submits boolean fields as changed even when it's not.

qshngqshng Posts: 9Questions: 5Answers: 0

I was having issue with main Editor submitting extra "null" fields when using submit changed.

Then I found this post and upgraded my Editor to the latest version which solves the issue.

https://datatables.net/forums/discussion/43548/editor-inline-submitting-extra-fields-when-using-submit-changed

However, after the upgrade, I'm still having issue with boolean type fields getting submitted as changed. Seems like boolean false was converted to string false or vice versa by the editor?

So I thought maybe I can check for if the boolean field has changed before the editor submits, something like in the example below, but not sure how to get it work exactly. Any help is appreciated!

    var openVals;
    editor
        .on( 'open', function () {
            // Store the values of the fields on open
            openVals = JSON.stringify( editor.get() );
             
            editor.on( 'preClose', function ( e ) {
                // On close, check if the values have changed and ask for closing confirmation if they have
                if ( openVals !== JSON.stringify( editor.get() ) ) {
                    return confirm( 'You have unsaved changes. Are you sure you want to exit?' );
                }
            } )
        } )
        .on( 'postCreate postEdit close', function () {
            editor.off( 'preClose' );
        } );
 

Answers

  • allanallan Posts: 63,075Questions: 1Answers: 10,384 Site admin

    Hi,

    Could you give me a link to your page so I can trace it through including being able to see the initialisation and data please?

    Thanks,
    Allan

This discussion has been closed.