Editor template remains in dom after editor.destroy()
Editor template remains in dom after editor.destroy()
After destroying an editor instance, the custom template defined on the configuration is remains into the dom. I'm following this example:
https://editor.datatables.net/examples/simple/template.html
I tried creating a test case on https://live.datatables.net/ but I'm getting an error when inserting the DataTables Editor library.
To solve this, a simple template.remove() is enough, but I assume editor.destroy() should take care of that? Or maybe I am doing something wrong?
This question has an accepted answers - jump to answer
Answers
Here is a simple test case:
https://live.datatables.net/guwafemu/640/edit
In the test case using
destroy()
doesn't remove the template. This is in thedestroy()
docs.It's not perfectly clear but I read this to mean that
destroy()
will remove anything the Editor library adds to the page. The template, while used by Editor, is not added by the Editor. You may want to use the template with another Editor instance.@allan can comment on whether he feels this is correct behavior.
Kevin
Many thanks for creating the test case Kevin.
Yes, I think I am happy with the current behaviour. Part of the idea there is that if you need to create a new instance and reference to the same template, the only way to do that would be to have the template element in the DOM.
As you say, a call to
.remove()
immediately after.destroy()
on the Editor instance will do it.Allan