我结合使用了AngularJS Utils分页指令和filamentgroup tablesaw响应表库来尝试获得响应(通过向右滑动)的分页表。
一旦我填充表,我从另一个名为responsive table的指令中调用tablesaw“刷新”事件,它使表完全响应,并且一切都很好。
$("tableselector").table("refresh")
但是,当我更改页面(因此表中的行会更改)时,表停止响应(如果检查HTML,我可以看到新行在'tr‘元素上没有相关的tablesaw类,而'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代码之后,我发现上面的代码总是在插入新行和调用refresh、destroy甚至create事件之后通过return语句退出。
其他人有这些问题吗?如果我不正确地使用任何一个库来刷新/销毁/重新创建响应表,他们知道如何使用吗?
发布于 2015-01-29 15:59:34
所以https://github.com/zachleat在GitHub上给我指出了正确的方向。
我必须稍微更改在用户单击以移动到下一个分页页面后刷新表的代码行。
$('#mytable').table().data("table").refresh()发布于 2015-09-27 00:19:03
因为tbody>tr>td是在调用refresh()之前加载的。这是偶然正确的。刷新函数不调用$cells.wrapInner( "“);$cells.prepend( "”+ html + "“);”
您可以更改源代码。使用init event instand of refresh事件。
https://stackoverflow.com/questions/28040732
复制相似问题