Run function after editing effect

Run function after editing effect

ggerbushggerbush Posts: 7Questions: 3Answers: 0

After an edit is made on a row, it has an effect where it turns yellow and fades back to white. I would like to run a function, but only after the effect takes place. If I try editor.on('submitComplete', myfunction()) it actually runs before the data in the table is even updated. Is there a way to run myfunction() after the visual effect is complete and the table is updated? I would like to do this, as it will make it more intuitive to the user that the data has been updated, before the table is changed by myfunction().

This question has an accepted answers - jump to answer

Answers

  • ggerbushggerbush Posts: 7Questions: 3Answers: 0

    I have also tried 'postEdit' in place of 'submitComplete' and got the same result.

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Hi,

    Currently I'm afraid no, there is no event that is triggered after the animation has taken place. What you could do though it use a setTimeout:

    editor.on( 'submitComplete', function () {
      setTimeout( function () {
        // ....
      }, 1050 );
    } );
    

    The animation lasts for 1050mS, hence the 1050 in the code above.

    Allan

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Hi @ggerbush ,

    If you want it after the submitComplete and postEdit, you'll need to add a listener to the draw. This, though, is called on every table draw (filter, page, ordering, etc), but you could set a flag in the edit so that you know the edit was the cause of the trigger,

    Cheers,

    Colin

  • ggerbushggerbush Posts: 7Questions: 3Answers: 0

    @allan Thank you! That worked perfectly!

    @colin Thanks for the response. I looked into using the draw event and I'm not sure if the table is redrawn after the animation, but in myfunction() it may redraw the table anyway depending on the change in data and I didn't want to cause a bunch of loops.

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    The animation happens after the table is redrawn - so yes, you'd still need to use the setTimeout method. Colin and I overlapped in our replies :).

    Allan

This discussion has been closed.