【发布时间】:2013-09-04 04:00:59
【问题描述】:
我有一组...非常...嵌套的表格。
这是我的 DOM:
<table id="sortable">
<thead>...</thead>
<tbody>
<tr class="draggable_item">
<td>
<table>
<thead class="show_this_while_dragging">...</thead>
<tbody class="hide_this_while_dragging">
<tr>
<td>...</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
table#sortable 中的每个 tr 都是可拖动的。当它被拖动时,我想将 tbody 隐藏在 each tr.draggable_item 内的表格中。
这是我如何初始化我的 sortable:
$( selector ).sortable({
helper: fixHelper
});
$( selector ).sortable( "option", "start", function(event, ui) { start_callback(selector) } );
function start_callback(selector)
{
$(selector + " table tbody").hide();
}
这几乎可以按预期工作。每个 tbody 都消失了,即使是被拖动的那个。但是 tbody 在当前拖动的项目中还有额外的空间。
我不确定是什么原因造成的,或者如何移除它。一旦我开始拖动项目,正在拖动的 tr.draggable_item 的高度就会被锁定。
【问题讨论】:
-
jsfiddle.net/ywF9E/3 - 您也会注意到,要将第 1 行拖到第 2 行下方,您必须将其拖到 tbody 未隐藏的位置下方。
-
detaching 元素而不是hideing 它们似乎没有效果。我相信问题出在开始事件上。我想我想要一个 beforeStart 事件。 -
我的问题与我认为的类似:stackoverflow.com/questions/9804238/…
标签: jquery jquery-ui jquery-ui-sortable