destroy() method not working

destroy() method not working

seiser01seiser01 Posts: 17Questions: 9Answers: 0
edited April 2014 in Bug reports
I'm trying to use the destroy method but it doesn't seem to be working.

[code]alert("creating table")

$(document).ready(function() {
apptDispTable = $('#tbl_appt').dataTable( {
"bDestroy": true
} );
}); // position 1

$(document).ready(function() {
try {
alert("about to destroy") // Position 2
apptDispTable.destroy();
} catch(err) {
DisplayPropertyNames(err) // Position 3
}
});
[/code]


[quote]Note: apptDispTable is a global variable.

1) Output at Position 2 shows my table created with DataTable functionality overlaid with the "about to destroy" alert box
2) Once the alert box is closed, the destroy() method is called which causes an error that is caught.
3) The error is displayed at position 3 and states: "Object doesn't support this property or method"

Why is this happening?
[/quote]

Replies

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin
    > $('#tbl_appt').dataTable(

    You are using the jQuery object, not the API instance. You should use `DataTable()` - see: http://next.datatables.net/manual/api#Accessing-the-API

    Allan
This discussion has been closed.