views:

44

answers:

2

I am using a jquery tablesorter plugin(http://tablesorter.com/docs/) for sorting my tables. This works for rows that created already. But when I add a row dynamically with Jquery clone() method, sorting is not working.

What I should I do to sort rows even if I add a row dynamically?

+1  A: 

$('.tablesorter').trigger('update'); after you add a row.

Tablesorter only scans through the table once, and after that it sorts on internally stored numeric or text values. It's quite clever, actually, as it makes the act of sorting super quick.

Stefan Kendall
Thanks this works
goutham
+1  A: 

The plugin has an example of an ajax update and it looks like you just have to trigger an "update" method on the table after you add your dynamic data.

Look here: http://tablesorter.com/docs/example-ajax.html

Code:

// let the plugin know that we made a update 
$("table").trigger("update"); 
fehays