当我在页面上只有一个表时,插件工作正常.
但有两个,我得到一个错误:
Uncaught TypeError: Cannot set property ‘count’ of undefined
这是因为下面设置了sortList选项.我将它设置为在第4列上排序,并且首先显示的aux_table只有3列.但它有效,而main_table则没有.我如何让他们两个都工作,或者只是第二个更重要的main_table?
两个表都是类tablesorter,它们有不同的id(main_table和aux_table).
页面上的第一个表可用,第二个表没有.这是来自我的< head>的JS标签:
$(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]] }); });
解决方法
您需要更改代码以在每个表上实例化表分类器,以便您可以为每个表指定单独的设置.
$("#table1").tablesorter({ sortList: [[3,1]] }); $("#table2").tablesorter();