2016-06-28 45 views
1

我正在試圖將一個表中的特定行拖到另一個表中。我看到使用LI和UL的演示,但我試圖用一個表格對象來做到這一點。我創建了一個JS小提琴,讓我有兩個不同的表格。使用jQuery將特定行拖到新表中可排序

我嘗試了不同的變化:

$("#selected-stock-grid, #stock-grid").sortable({ 
    connectWith: ".table-stock-content" 
}).disableSelection(); 

$("#selected-stock-grid, #stock-grid").sortable({ 
    connectWith: ".table-stock-content tbody" 
}).disableSelection(); 

$("#selected-stock-grid, #stock-grid").sortable({ 
    connectWith: ".table-stock-content tbody tr" 
}).disableSelection(); 

這裏是一個JS提琴: https://jsfiddle.net/3f0u86gL/

它只是試圖將整個表,而不是一個單獨的行。

回答

1

你需要在你的selectors更具體的,使用tbody元素,而不是整個表:

From the API

注:爲錶行進行排序時,TBODY必須進行排序,不是桌子。

$(function() { 
    $("#selected-stock-grid tbody, #stock-grid tbody").sortable({ 
    connectWith: ".table-stock-content tbody" 
    }).disableSelection(); 
}); 

Updated Demo

+1

偉大的作品,謝謝。 – user1048676

相關問題