Is this a bug in "destroy" option?
Is this a bug in "destroy" option?
daviddeh
Posts: 2Questions: 1Answers: 0
Hi everyone,
I have a simple JSFiddle to demonstrate the problem.
https://jsfiddle.net/ddehghan/j26d2pdx/2/
If i switch the data of DataTables between 2 different datasets I run into a script error. Am I doing something wrong?
Any help would be appreciated.
Thanks
David
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
So the issue here is that the tables are being constructed with a different number of columns. When you use
destroy
is leaves the table in the DOM, so if you click data 1 first you have a table with 3 columns - then load data 2, the configuration only has two columns but the HTML has three. Hence the issue.The answer is to use the
destroy()
method and$().empty()
: https://jsfiddle.net/j26d2pdx/7/Allan
Thanks you so much. that works very well. :-)