Problem when i rebuild my datatable

Problem when i rebuild my datatable

crzcrz Posts: 1Questions: 0Answers: 0
edited February 2012 in DataTables 1.9
Hello everyone, i'm using a simple method to bind my datatable, i retrieve the s and everything with an ajax call and use jquery's append() to insert them in the tbody of a table, then i apply .dataTable() to my table and everything works fine:
[code]
function BindTable() {
Ajax...
success: function (rsp) {
$("#myusers").find("tbody").empty();
$("#myusers").find("tbody").append(rsp);

if(firstInit){

$("#myusers").dataTable({ ... });
firstInit = false;
}
else $("#myusers").dataTable({ destroy = true });
}
[/code]


But since my interface requires the datatable to be updated without refresh of the page, i simply want to call my BindTable() again, appending the new set of rows, but when i call it a second time, i get a "Datatable could not be reinitialized" error, the new set of rows are appended but don't have any of the datatables formatting and when i use any feature of the datatables, like sorting, the old set of rows from the previous DOM are shown.

How can i remove the datatable completely and apply it again as to remove this undesirable behavior? Am i misusing the "bDestroy" option?
Thank you.
This discussion has been closed.