Sort JQuery table; problem with dynamically added rows

I am using the jquery tablesorter plugin ( http://tablesorter.com/docs/ ) to sort my tables. This works for already created lines. But when I add a line dynamically using the jQuery clone () method, sorting does not work.

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

+3
source share
2 answers

$('.tablesorter').trigger('update'); after adding a line.

Tablesorter only scans the table once, and then sorts the internally stored numeric or text values. This is pretty smart, actually, as it makes the sorting process super fast.

+6

ajax, , "" .

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

:

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

Source: https://habr.com/ru/post/1764997/


All Articles