我做了一个快速列表,其中每个项目都可以移动到垃圾桶。我设置了它,所以一旦你将它追踪到垃圾箱上,它就会隐藏起来。如果您对“确认”点击“确定”,则使用 remove() 将其完全删除。
问题是,如果我单击取消进行确认,它会保持隐藏状态(但我希望它再次显示,因为它会回到原来的位置,就像隐藏一样)。我尝试在许多地方使用 ui.draggable.show(),但没有运气。有什么建议吗?
这是 JSFiddle:http: //jsfiddle.net/Gdze8/6/
Javascript/jQuery:
$( init )
function init() {
$(".contentItem").draggable({
revert: function (event, ui) {
if ($(event[0]).closest('.list4').length ) {
var state = !confirm("Are you sure you want to delete?")
if (!state) {
$(this).remove();
bottomInfo();
} else {
return state;
}
} else {
return true;
}
}
});
$(".list4").droppable( {
accept: ".contentItem",
drop: function(event, ui) {
ui.draggable.hide();
return true;
}
});
}