Editor - Additional clean up for field types

Editor - Additional clean up for field types

rduncecbrduncecb Posts: 125Questions: 2Answers: 28

Some field types such as selectize require additional cleanup to remove DOM nodes, events etc.
The Editor destroy function is useful for cleaning up an Editor instances, particularly important in a single page application.
It would be useful if plugins could implement their own destroy function to clean up after themselves and Editor destroy would execute plugin/field type destroy functions if they have one.

Currently, creating an Editor with a selectize field type leaves the selectize DOM elements after calling destroy so have to be cleaned up manually. Field Types that are implemented as plugins can not currently be cleaned up using the Editor API (as far as I can tell, please correct me if I'm wrong ;) ).

Replies

  • allanallan Posts: 63,573Questions: 1Answers: 10,483 Site admin

    It looks like I've failed to document this. You can actually have a destroy function on a field plug-in. I'm not sure why that slipped through, but I'll get it added - thanks!

    I'll also look into updating the plug-ins that are available to make use of it.

    Regards,
    Allan

  • rduncecbrduncecb Posts: 125Questions: 2Answers: 28

    Hmm, I take a closer look, I added a destroy function to my selectize plugin and it failed to get called. Possibly my error, will get back here if not.

  • rduncecbrduncecb Posts: 125Questions: 2Answers: 28

    Can confirm, destroy() function in a field type plugin function works and is called as part of destroy. Many thanks.

This discussion has been closed.