0
當我從下拉列表中刪除可拖放項目時,應將其添加到可拖動列表中。需要編碼幫助:將其拖放回復
可以請你幫我編碼,我可以如何使它在拖動列表中再次可見。
HTML:
<div class="draggable"> <div class="cs-drop">drag 1
<a href="#"> remove</a></div></div>
<div class="draggable">drag 2</div>
<div class="draggable">drag 3</div>
<div style="clear: both;"></div>
<div class="droppable">drop here</div>
<div class="droppable">drop here</div>
<div class="droppable">drop here</div>
CSS:
<style>
.draggable { padding: 40px 25px; border: 1px solid red; float: left;}
.droppable { width: 100px; height: 100px; border: 1px solid black; float: left; }
.droppable.active { background-color: red; }
</style>
JS:
<script>
$('.draggable').draggable({ revert: true });
drop();
function drop()
{
$('.droppable').droppable({
hoverClass: 'active',
drop: function(e, ui) {
$(this).html($(this).html()+ui.draggable.remove().html());
$(this).droppable('destroy');
}
});
}
$(".droppable").on("click", "a", function(){
$(this).closest('.cs-drop').fadeOut(200, function() {$(this).remove();});
drop();
});
</script>
工作正常。但是在刪除drag1之後,它會被添加到拖動列表中。同樣的drag1需要放下。這是可能的 – naresh 2015-03-19 04:53:58
是有可能的!您將需要以不同的方式實現代碼! – 2015-03-19 04:55:16