jQuery infinite loop w/ tablesorter
Posted
by Wells
on Stack Overflow
See other posts from Stack Overflow
or by Wells
Published on 2010-06-01T18:19:19Z
Indexed on
2010/06/01
19:14 UTC
Read the original article
Hit count: 179
JavaScript
|jQuery
Got myself in a funny situation: page has three tables. Using sortEnd, any time you sort one table, it sorts the other three. However, since I bound sortEnd to the function that does the sorting, you get a infinite loop of sorting/resorting. It looks like:
$("table.tablesorter").tablesorter({widgets: ['zebra']}).bind("sortEnd", function() {
$(this).find("th.headerSortDown,.headerSortUp").each(function(i) {
index = $(this).attr("cellIndex");
order = ($(this).is(".headerSortDown")) ? 1 : 0;
$("table.tablesorter").tablesorter({sortList: [[index,order]]});
});
});
Any tips on how to clean this up?
© Stack Overflow or respective owner