jquery tablesorter 动态添加数据时,排序有误。
2013-12-17 14:45
295 查看
,我从后台动态加载表格,然后运用tablesorter,然后动态更改表格中的数据,排序不会按照更改后的数据进行排序,会按照之前的数据进行排序,?
解决方法。在动态修改数据后,使用$("#scroll").trigger("update");就行了。
官网实例:
$(document).ready(function() {
$("table").tablesorter();
$("#ajax-append").click(function() {
$.get("assets/ajax-content.html", function(html) {
// append the "ajax'd" data to the table body
$("table tbody").append(html);
// let the plugin know that we made a update
$("table").trigger("update");
// set sorting column and direction, this will sort on the first and third column
var sorting = [[2,1],[0,0]];
// sort on the first column
$("table").trigger("sorton",[sorting]);
});
return false;
});
});
解决方法。在动态修改数据后,使用$("#scroll").trigger("update");就行了。
官网实例:
$(document).ready(function() {
$("table").tablesorter();
$("#ajax-append").click(function() {
$.get("assets/ajax-content.html", function(html) {
// append the "ajax'd" data to the table body
$("table tbody").append(html);
// let the plugin know that we made a update
$("table").trigger("update");
// set sorting column and direction, this will sort on the first and third column
var sorting = [[2,1],[0,0]];
// sort on the first column
$("table").trigger("sorton",[sorting]);
});
return false;
});
});
相关文章推荐
- jquery tablesorter 动态添加数据时,排序有误。
- 新学的插件jquery.tablesorter很好用,说说遇到的表格动态添加的数据不能排序的问题
- jQuery html表格排序插件:tablesorter
- jquery 动态控制表格,添加,删除,上移,下移,排序
- 使用jQuery动态创建一个表格,根据用户数输入的内容添加一行数据
- 改进jquery.tablesorter.js 支持中文表格排序
- vue.js 利用SocketCluster实现动态添加数据及排序
- 应用jQuery实现表格数据的动态添加与统计
- jQuery表格排序组件-tablesorter
- jQuery 表格排序插件 Tablesorter 使用
- jQuery - 动态添加、删除form表单项(附:新增项数据无法提交问题解决)
- 使用jQuery动态创建一个表格(根据用户输入的内容添加一行数据,并且能逐行删除)
- jquery tablesorter插件 表格排序
- jquery将数据以table的形式显示,实现数据统计,分页,以及动态添加,搜索
- jquery动态添加删除一行数据
- jquery动态添加删除一行数据示例
- jQuery 实时保存页面动态添加的数据的示例
- jQuery表格排序组件-tablesorter使用示例
- jquery tablesorter表格排序插件的使用
- jQuery 表格排序插件 Tablesorter 使用