http://jsfiddle.net/nalberg/E3nBu/4/
对此有什么帮助吗?我在使用时得到重复的行: knockout :http://knockoutjs.com/和 jquery.tablesorter 插件:(http://tablesorter.com/docs/)。
基本上,第一次加载所有内容时......效果很好。但是,如果我在对表进行排序后替换或更改绑定(bind)到 knockout 数据的数据......我开始得到重复的行。每个人似乎都在创建和维护自己的行集。
最佳答案
您可以清除绑定(bind)到表的数组,例如
YourViewModel.list.clearAll();
透明 table 体
$(".gridtable").find('tbody').empty();
更新表格排序器
$(".table_border").trigger("update");
所以你的数据加载函数可能看起来像这样
self.Load = function () {
self.list.removeAll();
$(".gridtable").find('tbody').empty();
$.ajax('/List', {
data: $('#yourformname').serializeArray(),
global: true,
contentType: "application/json; charset=utf-8",
type: "Get", contentType: "application/json",
success: function (result) {
var mappedList = $.map(result, function (item) { return new List(item) });
self.List(mappedList );
$(".table_border").trigger("update");
}
});
};
关于jquery - KnockoutJs 与 Jquery.tablesorter - 导致重复行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8900259/