How to call multiple fnDraw()'s in a row?

How to call multiple fnDraw()'s in a row?

TechRayTechRay Posts: 7Questions: 0Answers: 0
edited October 2013 in General
I have a tabbed container with different data tables loaded simultaneously. On one of the tabs you can update information that is reflected across the others so my goal here was to make all of them reload their server side processed data. I thought I could do it simply with something like the function below (I 'remake' each table into a data table as some where giving me the 'element has no function .datatable()' error) but the ajax calls get in the way of each other and throw JSON formatting errors.

Is there some way to have these tables consecutively update without hardcoding a thread timeout. I also tried just to 'fnDestroy()' the other tables so that when the user went back to those tabs they would reload, but the fnDestroy left the data and everything instead of removing the table.

[code]function updateAllOpenDataTables(){
var tables = $j.fn.dataTable.fnTables();
for(x in tables){
tables[x] = $j(tables[x]).dataTable();
tables[x].dataTable().fnDraw();
}
}[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    It looks like you have one too many calls to dataTable() there. Remove the one in the fnDraw line and it looks like it would work.

    Allan
This discussion has been closed.