using preSubmit to prevent ajax call

using preSubmit to prevent ajax call

xfloydxfloyd Posts: 35Questions: 12Answers: 1

Great job on the Editor. I have one issue, is there a easy way to when inline with tab, to stop Ajax calls if data does not changes. I got this far, bat I'm stuck.
```
var openVals;

            editor3
                .on( 'open', function ( e, type ) {
                    if ( type === 'inline' ) {
                        openVals = JSON.stringify( editor3.get() );
                   ...

                .on( 'preSubmit', function ( e ) {
                    if ( openVals == JSON.stringify( editor3.get() ) ) {
                        //something to put here to stop Ajax and change filed back to text???
                    }
                } );

This question has an accepted answers - jump to answer

Answers

  • xfloydxfloyd Posts: 35Questions: 12Answers: 1

    OK, that was easy. I added close() and it works now. Is that the best way to handle that?
    ```
    .on( 'preSubmit', function ( e ) {
    if ( openVals == JSON.stringify( editor3.get() ) ) {
    editor3.close();
    return false;
    }
    } );

  • xfloydxfloyd Posts: 35Questions: 12Answers: 1

    Well, it's not working too good, tabbing now is not working. Please help.

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin

    to stop Ajax calls if data does not changes

    This is something that will be built into Editor 1.5 which will be available next week. If you can hang on until that release it will "just work".

    Allan

  • xfloydxfloyd Posts: 35Questions: 12Answers: 1

    Awesome, do you have docs on how will it work?

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin
    Answer ✓

    The documentation for 1.5 hasn't been published yet (it will be when 1.5 is available). However, it does this internally - no additional code is required. It will check to see if there are any changes before submitting the data, and if not it just executes the form close code. There is also an option to have it submit, even if there is no change, but that is not enabled for inline editing.

    Allan

This discussion has been closed.