javascript - 添加新行后不能 "refresh"filamentgroup tablesaw 响应表

标签 javascript jquery html angularjs tablesaw

我正在结合使用 AngularJS Utils 分页指令和 filamentgroup tablesaw 响应式表格库来尝试获得响应式(通过向右滑动)、分页表格。

填充表格后,我从另一个名为响应表的指令中调用 tablesaw“刷新”事件,它使表格完全响应,一切都很好。

$("tableselector").table("refresh")

但是,当我随后更改页面(因此表中的行发生变化)时,表停止响应(如果您检查 HTML,我可以看到新行在 'tr 上没有相关的表锯类' 元素,而 'th' 元素仍然存在)。

我有点预料到这一点,并尝试再次调用刷新事件,但没有成功,所以我尝试了销毁事件,但似乎也没有成功!

以下是我的 HTML 供引用。

<table class="table table--stripe" data-mode="swipe" responsive-table>
  <thead>
    <tr>
      <th>Email</th>
      <th>Name</th>
      <th>User role</th>
      <th></th>
    </tr>
  </thead>

  <tbody>

    <tr dir-paginate="user in Model.Users | itemsPerPage:Model.PageSize" current-page="Model.CurrentPage">
      <td>{{user.Email}}</td>
      <td>{{user.DisplayName}}</td>
      <td>{{user.Role}}</td>
      <td>{{user.Telephone}}</td>
    </tr>
  </tbody>
</table>

我已经大致找到了 tablesaw 代码出现“错误”的地方(尽管我怀疑这只是我缺乏理解)

 $.fn[pluginName] = function ()
    {
        return this.each(function ()
        {
            var $t = $(this);

            if ($t.data(pluginName))
            {
                return;
            }

            var table = new Table(this);
            $t.data(pluginName, table);
        });
    };

在查看了很多 tablesaw 代码后,我发现上面的代码总是在插入新行并调用刷新、销毁甚至创建事件后通过 return 语句退出。

有没有其他人遇到过这些问题,或者知道如果我错误地使用任一库来刷新/销毁/重新创建响应表会怎样?

最佳答案

所以我在 GitHub 上被 https://github.com/zachleat 指出了正确的方向.

在用户点击移动到下一个分页页面后,我不得不稍微更改刷新表格的代码行。

$('#mytable').table().data("table").refresh()

关于javascript - 添加新行后不能 "refresh"filamentgroup tablesaw 响应表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28040732/

相关文章:

javascript - 开 Jest 比较值没有视觉差异。测试数组时

javascript - jquery ui selectable如何停止选择内部元素?

html - CSS - 移动网站响应异常?

javascript - 点击事件和for循环

javascript - keydown() 并按住一个键

javascript - 如何获取下一个元素,而不管它是否是兄弟元素?

javascript - JQuery 开发标准

javascript - 如何重构这个要排序的对象表?

javascript - onscroll 添加事件类不起作用

javascript - 有没有办法从两个标签之间提取文本,并以我选择的格式输出?