【发布时间】:2014-03-10 08:23:14
【问题描述】:
您好,我正在使用带有分页器的 jquery 表排序器。我有四个表和每个分页器。单击按钮时显示表和相应的分页器。单击第一个和第二个按钮时,表的分页器工作正常。
但是在点击第三个和第四个按钮时,我得到了 以下错误“Uncaught TypeError: Cannot set property 'widgets' of undefined”并且寻呼机不工作。
Code called in OnLoad:
$("#tableTest").hide(); // Hide the table in onload
$("#tableTest").tablesorter(); // Trigger the tablesorter in onload
$("#tableTest").trigger("update"); // Trigger the update function for table in onload
$("#tableTest").tablesorterPager({ container: $("#pagerTest") }); // Trigger the pager for table in onload
Code After displaying the table
$("#tableTest").trigger("update");
$("#tableTest").data("tablesorter").widgets = ["zebra"];
$("#tableTest").trigger('applyWidgets');
$('header,body,html').animate({ scrollTop: $('header').height() }, 4);
请指导我出了什么问题,我哪里错了。第三张和第四张桌子的寻呼机不能正常工作。
【问题讨论】:
-
您能否展示所有四个表的代码以及如何更新它们...对我来说,这听起来像是一个表(而不是 tbody 的内容)正在被完全替换,而 tablesorter 是未重新初始化 -
trigger("update")仅适用于 tbody 更新。
标签: javascript jquery jquery-plugins tablesorter