Replacing the tbody of a table then calling draw() is overwriting the new data with cached data.
Replacing the tbody of a table then calling draw() is overwriting the new data with cached data.
Example: http://live.datatables.net/deqalab/edit
I have converted a table in my application to use DataTables 1.10.1. There is a button on the table that will load new data into it by calling $("#table tbody").load(). The table does not display properly as it needs to be redrawn, as you can see if you comment out the draw() call in my example. However, calling draw() is overwriting the new data with the old. Is this a bug or is there something wrong with my implementation?
This question has an accepted answers - jump to answer
Answers
I've modified your example so that it works, although you may not be pleased with how I've done it. I've also added a button so that you can visibly see the change happen.
Do your table updates come to you as pre-formed HTML
<tr>
tags? If you can get the direct data, there are better ways to update the table, such as using therow.add()
method.Thanks. I've used a modified version of your example as my solution that doesn't require a wrapper class.
http://live.datatables.net/sidahil/2/edit
Awesome! TIL what
destroy()
does, so thank you! :)