Jquery 在敲除数组中追加,给出重复的行
将新行添加到使用Jquery TableSorter排序的敲除可观察数组中会将行添加两次,这会导致现有行的重复。PFB my code:Jquery 在敲除数组中追加,给出重复的行,jquery,ajax,knockout.js,tablesorter,Jquery,Ajax,Knockout.js,Tablesorter,将新行添加到使用Jquery TableSorter排序的敲除可观察数组中会将行添加两次,这会导致现有行的重复。PFB my code: <tbody data-bind="foreach: jarFiles"> //jarFiles:KnockoutArray <td><span data-bind="text: fileName"></span></td>
<tbody data-bind="foreach: jarFiles"> //jarFiles:KnockoutArray
<td><span data-bind="text: fileName"></span></td>
<td><span data-bind="text: name"></span></td>
<td>...</tbody>
排序后,我尝试更新表格格式的数组,它返回重复项:
that._replace = function(newList) {//newList=oldList+newelement
that.jarFiles.removeAll()
var i=newList.length;
_.each(newList, function(jar){
that.jarFiles.push(jar);
});
使用ajax加载页面
我不知道如何使用击倒。。。所需的是在添加新内容后触发“更新”-触发器('update')代码>触发更新没有帮助。它不起作用。
that._replace = function(newList) {//newList=oldList+newelement
that.jarFiles.removeAll()
var i=newList.length;
_.each(newList, function(jar){
that.jarFiles.push(jar);
});
that._replace = function(newList) {
that.jarFiles.removeAll();
$(".display").find('tbody').empty(); // To clear table body
_.each(newList, function(jar){
that.jarFiles.push(jar);
});
$(".display").trigger("update"); // To update the tablesorter
};