2016-03-02 15 views
0

添加新行被使用jQuery的tablesorter排序的淘汰賽觀察到的陣列增加了兩倍行,這會導致現有rows.PFB我的代碼重複:附加在淘汰賽陣列給人重複的行

<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> 

的排序基於點擊施加上的前兩行:

$("#fileName").click(function() {              
    $("#display").tablesorter(); 
}//Invokes tablesorter on click function for fileName column 

分揀我嘗試更新排列的以表格形式後,它返回重複:

 that._replace = function(newList) {//newList=oldList+newelement    
        that.jarFiles.removeAll() 
        var i=newList.length; 
        _.each(newList, function(jar){ 
         that.jarFiles.push(jar); 
        }); 

使用ajax加載頁面。

enter image description here

+0

我不知道如何使用淘汰賽......我們需要的是觸發「更新」的新內容已添加後 - '$(「#顯示」)。 ('update');' – Mottie

+0

http://stackoverflow.com/questions/14593367/how-to-work-with-jquery-table-sorter-with-knockout –

+0

觸發更新不起作用。它不起作用。 – Somekindofcoder

回答

0
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 
};