我有一些表,例如:jquery-ui sortable:如何在拖動時添加單元格?
<table class="table table-hover table-striped" id="mytable">
<thead>
<tr>
<th>#</th>
<th>Table heading 1</th>
<th>Table heading 2</th>
<th>Table heading 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Table cell</td>
<td>Table cell</td>
<td>Table cell</td>
</tr>
</tbody>
</table>
然後我要讓排序表中的行頭。
$('#mytable thead tr').sortable({
axis: "x",
helper: "clone"
}).disableSelection();
問題:
當我開始將正掉落,我有6 th
-s代替4-:
<tr class="ui-sortable">
<th>#</th>
<th style="
display: none;">Table heading 1</th>
<th class="ui-sortable-placeholder"
style="
visibility: hidden;"></th>
<th>Table heading 2</th>
<th>Table heading 3</th>
<th style="
display: table-cell;
width: 343px;
height: 37px;
position: absolute;
z-index: 1000;
left: 184px;"
class="ui-sortable-helper">Table heading 1</th>
</tr>
..和所有的加價開始非常不穩定並且不確定:當我將th
項目拖動到表格上時,我看到所有行都跳起來了。
很明顯,這是因爲計數th
項(它不等於tr
中的td
項數)。
如何修復?
這個庫做到了這一點:http://www.danvk.org/wp/dragtable/ – rusln