带有动态添加行的jquery tablesorter的问题 [英] problem with jquery tablesorter with dynamic added rows
本文介绍了带有动态添加行的jquery tablesorter的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好我遇到了动态添加行到jquery tablesorter的问题,
hello i am having a problem with dynamically added rows to jquery tablesorter,
我必须在表的开头添加一行,默认情况下tablesorter工作很好但是在添加了行之后,表格只排序使用前面的行排序我的意思是新行不包含在排序过程中,新行有一些但不是所有字段都空白任何解决方案?
i have to add a row in the beginning of the table, by default the tablesorter works fine but after the row is added, the table sorted only sorts using the previous rows i mean that the new row is not included in the sorting process, the new row has some but not all fields blank any solution?
推荐答案
tablesorter网站提供了如何执行此操作的详细信息,请访问:使用Ajax附加表数据。代码转载如下:
The tablesorter website offers details of how to do this, at: Appending table data with Ajax. The code is reproduced below:
$(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
// updateAll ensures sorting is updated as well
$("table").trigger("updateAll");
// 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的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文