在两个表之间拖放

我试图在两个表之间拖动n行。 第一个表有3列,第二个表有4列。 我有拖拉机工作。

我见过的所有例子一般都是在掉线位置附加的。 我想要做的是替换拖动行的内容并替换/更新删除位置中的单元格。

我在想是否可以编写一个新的tablerow(..),然后删除当前删除的行并将其替换为生成的行。 或者只是更新新位置的列。

(function ($) { $(document).ready(function () { var tb1 = $("#table1 tr"); var tb2 = $("#table2 tr"); tb1.draggable({ appendTo: "body", helper: "clone", opacity: "0.35", revert: "invalid" }); tb2.droppable({ accept: '#table1 tr', tolerance: "pointer", drop: function (event, ui) { //loop through all items in the row var $col1, $col2; tb1.each(function () { $col1 = $("span:eq(0)", this).text(); $col2 = $("span:eq(1)", this).text(); }); $droppedRow = $(this).children('td'); var $destCol1 = $droppedRow.find('span')[0].innerHTML; var $destCol2 = $droppedRow.find('span')[1].innerHTML; var $row = "" & $destCol1 & "" & $destCol2 & "" & $col1 & "" & $col2 & ""; } 

http://jsfiddle.net/S2yC2/7/

任何建议如何进行。 谢谢

我想你正在尝试这样做: http : //jsfiddle.net/S2yC2/15/

  drop: function (event, ui) { //Retrieve relevant data of the dragged line var $draggedCol = $(ui.draggable).children('td'); var col1 = $($draggedCol[0]).html(); var col2 = $($draggedCol[1]).html(); //Assign data to the void cell of the dropped line var $droppedRow = $(this).children('td'); $($droppedRow[2]).html(col1); $($droppedRow[3]).html(col2); }