12
我現在可以將項目拖到可排序列表中。但是可排序列表具有不同的DOM。jQuery:可拖動連接可排序。可拖動項目具有與可排序列表不同的DOM
<!-- The draggable items. Has the "original" DOM in the LI tags. -->
<ul class="draggable_text">
<li><span>DRAG THIS A</span></li>
<li><span>DRAG THIS B</span></li>
</ul>
<!-- This list has a different DOM in the LI tags -->
<ul id="stagerows">
<li><p>This is a new DOM dragged from "DRAG THIS A"</p></li>
<li><p>This is a new DOM dragged from "DRAG THIS B"</p></li>
</ul>
$(document).ready(function() {
$('.draggable_text > li').draggable({
//helper:'clone',
helper: function(event, ui) {
return '<div style="width: 100px; height: 50px; border: 1px solid #000; background-color: #fff;">xxx</div>';
},
connectToSortable:'#stagerows'
});
$('#stagerows').sortable({
handle: '.drag_handle'
});
});
助手有這樣的: XXX 這應該投進排序...
的 「幫手」 的作品。但是,當我將這個項目「丟棄」到可排序的項目中時,它只會回覆到「原始」DOM。我希望將「新創建的DOM」(在助手中創建的那個)放入可排序的對象中。
我希望我有道理。謝謝!
另一種說法: 當我拖動一個蘋果,它現在變成了一個橙色。但當我放下它時,它變回了一個蘋果..