Getting a list of Editors on the page

Getting a list of Editors on the page

Loren MaxwellLoren Maxwell Posts: 387Questions: 94Answers: 10

I know I can use this function to get a list of the DataTables, $.fn.dataTable.tables(), but is there an equivalent function to get a list of the Editors?

I've looked through the $.fn.dataTable.Editor functions but I don't see anything obvious.

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Answer ✓

    Sorry to say, there isn't. The Editor instances do not get stashed in a "store" - they exist only in the scope they were created (and then passed on to), and via their event handlers.

    There is an initEditor event that Editor fires on the document when an instance is created though. So if you wanted to create such a store, listen for that and add them to the store. One catch there is that there isn't currently a destroy event to match that. Perhaps there should be...

    Allan

  • Loren MaxwellLoren Maxwell Posts: 387Questions: 94Answers: 10
    edited July 2023

    Thanks, @allan -- I think having something would help.

    I show a table in the child rows and create a DataTable instance for each child row and an Editor instance for each child row as well, and I currently have to guess if I'm destroying the Editor instances properly.

    If I had a way to track all the Editor instances like the DataTables instances then I'd clearly see if I'm doing it correctly.

  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Answer ✓

    I think it s a sensible idea. I've added a destroyEditor event into the destroy() method which will ship in the next release. If you want to use it immediately, add:

    $(document).trigger('destroyEditor', [this]);
    

    immediately before this.dom = null; in that method.

    Between this new event and initEditor it would now be possible to keep a store of Editor instances on the page.

    Allan

  • Loren MaxwellLoren Maxwell Posts: 387Questions: 94Answers: 10

    Perfect! Thanks!

Sign In or Register to comment.