In SO: DataTables with different number of columns the user asked for a solution to work with datatables.js and variable amount of columns. A working solution was provided here: http://jsfiddle.net/gss4a17t/ .
This solution depends on a deprecated function:
dataTable.fnDestroy(true);
Questions:
destroy()
function not work here? $('table.dataTable').DataTable().destroy();
and $('dataTable').DataTable().destroy();
in this situation? i forked with the following jsFiddle: http://jsfiddle.net/Lx4mf1ht/7/
1) destroy()
needs a DataTable object to work. It's a method of this kind of object. fnDestroy()
is a method of a dataTable object.
dataTable is different object when compared to DataTable (check the captilized D). They have different methods and that's why destroy()
should not work.
2) 'table.dataTable'
is used as a jQuery selector where it looks for a <table>
element with a dataTable
class which is OK
'dataTable'
is a selector looking for a <dataTable>
element I assume this one does not work since there is no such element.
Also, I am not sure what version of DataTables fiddle uses, but destroy() is there since v1.10
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.