0

Im using a jquery plugin called tablesorter to sort tables when one of the headers is clicked. However, the table im using is capable of losing/gaining and changing rows. So the HTML is changing, but the tablesorter plugin is not recognizing these changes. So the tablesorter plugin adds old rows when initiated.

I've created an example here: http://jsfiddle.net/mgtc24d8/9/. You can see the issue by clicking "Delete row", then sorting the table by clicking one of the headers. It will re-add the deleted row.

code
Barmar
  • 741,623
  • 53
  • 500
  • 612
Josh
  • 153
  • 5
  • 18
  • 1
    Most likely because the plugin caches the entire table in an array so it can rewrite it all at once when it sorts (if you know about JQuery writing individual DOM elements is taxing on performance). Therefore you need to force it to re-cache after you delete a row. – marblewraith Oct 04 '14 at 01:15
  • 1
    [tablesaw](https://github.com/filamentgroup/tablesaw) could be a good alternative – J-Dizzle Oct 04 '14 at 01:15

1 Answers1

2

Thank you for the comments, you helped me find the answer.

Tablesorter allows you to update the table (clear the cache) after the table has been updated by using the following.

$("table").trigger("update"); 
Josh
  • 153
  • 5
  • 18