我希望能够从droppable列表中删除项目。用户可以将项目拖放到可放置区域,并且可以防止重复相同的项目。现在我想通过拖出项目从列表中删除项目。怎么做?这是脚本即时使用:
$(function () {
$("#myAccordion").accordion({heightStyle:"content", active: false, collapsible:true});
$("#myAccordion li").draggable({
connectToSortable: '.container',
helper: 'clone',
create: function () {
var eq = $(this).index();
$(this).attr('data-index', eq);
}
});
$(".container").sortable({
connectWith: '.container',
placeholder: "ui-state-highlight",
receive: function (event, ui) {
var uiIndex = ui.item.attr('data-index');
var item = $(this).find('[data-index=' + uiIndex + ']');
if (item.length > 1) {
item.last().remove();
}
},
revert: true
});
$(".container li").draggable({
connectToSortable: '.container',
placeholder: "ui-state-highlight",
revert: true
});
});