Marcus
Marcus

Reputation: 9459

jQuery Tablesorter - in IE it reverses the sort order every time I trigger the sort operation

I make an AJAX call and update numerical values in a column of my table (I don't append new rows or delete existing rows, just update the values inside the column I wish to sort on).

After the AJAX call is successful, I just run: $("#myTable").tablesorter( {sortList: [[4,0]]} ); to sort on column 4 in ASC order.

However in IE, every time the above code runs, it reverses the current order. So the table flips from being ordered ASC to DESC to ASC to DESC...

I tried instead calling $("#myTable").trigger("update"); but this still switches the sort order in IE.

Any idea how to sort this?

Thanks!

Upvotes: 0

Views: 341

Answers (1)

Beetroot-Beetroot
Beetroot-Beetroot

Reputation: 18078

In tablesorter, after inserting/modifying the table you have to .trigger("update") and .trigger("sorton", ...) to reimplement the current sort.

However, due to the way "update" is implemented, you can't simply have two consecutive statements, .trigger("update") followed by .trigger("sorton", ...). This is counter-intuitive and generally regarded as a bug.

The whole thing is perfectly explained here. Apply the suggested patch to your copy of tablesorter, and use the following single statement to achieve the combined affect of updating tablesorter's internal representation of the table and re-applying the current sort:

$("#myTable").trigger({type:'update', resort:true});

Upvotes: 1

Related Questions