【问题标题】:jquery tablesorter pager is not workingjquery tablesorter 寻呼机不工作
【发布时间】: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


【解决方案1】:

显然,$("#tableTest").data("tablesorter") 返回null。 您确定 tablesorter 将其初始化数据存储在 .data('tablesorter') 中吗?您使用的是哪个 tablesorter 插件(有几个)?

【讨论】:

  • 我已使用此链接link 中的示例代码,但我无法理解您关于初始化数据的问题
  • tablesorter 至少从版本 2.0.5(在 tablesorter.com)开始,就将其 config 变量存储在 .data('tablesorter') 中。
猜你喜欢
  • 1970-01-01
  • 2012-07-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多