How to have multiple jQuery TableSorter tables per page

The plugin works fine when I have only 1 table per page.

But with two, I get an error:

Uncaught TypeError: Unable to set 'count' value from undefined

This is due to the option sortListset below. I set it to sort in the 4th column, and aux_tableonly 3 columns displayed . But it works, but main_tablenot. How do I get them to work, or just a second, more important main_table?

Both tables are classes tablesorter, and they have different identifiers ( main_tableand aux_table).

The first table on the page works, and the second does not. Here is the JS from the tag <head>:

$(document).ready(function() { 
    // call the tablesorter plugin 
    $("table").tablesorter({ 
        // sort on the 4th column (index 3) column, DESC (1). ASC is (0). 
        sortList: [[3,1]] 
    });    
});
+5
source share
3

, , .

$("#table1").tablesorter({ 
   sortList: [[3,1]] 
}); 

$("#table2").tablesorter();
+5

, . , , .

 $(document).ready(function() {
   $('.pearl-container').each(function(i) {
     $(this).children(".myTable")
       .tablesorter({
         widthFixed: true,
         widgets: ['zebra']
       })
       .tablesorterPager({
         container: $(this).children(".pager"),
         size: 5
       });
   });

 });
Hide result

, .

http://www.pearlbells.co.uk/table-pagination/

0

What about class choices?

$(".tablesorter").tablesorter(); 

if you need to sort by several tables.

0
source

All Articles