我遇到了这个特殊问题:当我将一个draggable拖放到droppable然后删除这个draggable(draggables是“文件和文件夹”而droppable是“Trash Bin”)时,在“drop事件”的回调中“,javascript落到了无限循环中。我的确切代码是:
$("#trash").droppable({
over : function () {$("#trash").addClass("over")},
out : function () {$("#trash").removeClass("over")},
drop : function (e, ui) {
$("#trash").removeClass("over");
var id=$($(ui.draggable).parent()).attr("id"), fl=false;
$($(ui.draggable).parent()).hide();
$(".ui-draggable-dragging").remove();
if (id[1]=='l') {
fl=true;
id=flid(id);
}else{
id=fid(id);
}
$.post("ajax/recycle_file.php", {fid : id, folder : fl}, function (data) {
var elid=$($(ui.draggable).parent()).attr("id");
$("#"+elid).draggable("destroy");
$("#"+elid).remove(); //Here is where the endless loop starts
});
}
});
我从谷歌浏览器的javascript控制台收到的消息是:
Uncaught TypeError: Cannot read property 'options' of undefined