I'm not sure why I'm having so much trouble with this.. I'm trying to destroy a table. The error is: Uncaught TypeError: Cannot read property 'dt' of undefined
Code:
I have a function that's triggered by a dropdown select menu.
var table
function onChange() {
if ( table != null ) {
table.destroy();
$("#weeklySalesTable").empty();
}
...
table = $('#weeklySalesTable').DataTable( {
"scrollY": "600px",
"scrollX": true,
"paging": true,
"lengthMenu": [ [25, 50, 100], [25, 50, 100] ],
"info": true,
"deferRender": true,
"ordering": false,
"fixedColumns": true,
"scrollCollapse": true,
} );
}