Can you create a new record in the callback function of event edit ?

Can you create a new record in the callback function of event edit ?

Chandler242Chandler242 Posts: 36Questions: 12Answers: 0
edited May 2019 in Free community support

Here is my sample code:

editor.on('edit', function (e, json, data) {

     editor
            .create( false)
            .set('first_name', 'John')
            .set('last_name', 'Smith')
            .submit();
}

After the editing was completed, the new record wasn't created. Similarly I created a button to edit a record and then add a new record like this:

editor.edit()
editor
         .create( false)
         .set('first_name', 'John')
         .set('last_name', 'Smith')
         .submit();

The new record wasn't created.

It seems that one callback function can only make one form submit. Could anyone confirm that?

Thank you.

Yong

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598
    Answer ✓

    Hi @Chandler242 ,

    The edit is called before the previous edit has completed - you need to add you code to submitComplete which is called once the previous edits have all finished. This thread has an example of this,

    Cheers,

    Colin

  • Chandler242Chandler242 Posts: 36Questions: 12Answers: 0

    Hi Colin, Thank you so much. The example shows exactly what I was trying to do.

    Regards,

    Yong

This discussion has been closed.