1

I am having this particular problem: When I drop a draggable onto a droppable and then delete this draggable (The draggables are "files and folders" and the droppable is "Trash Bin"), inside the callback of the "drop event", javascript falls to endless loop. My exact code is:

$("#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
        });
    }
});

The message I get from the javascript console of Google Chrome is:

Uncaught TypeError: Cannot read property 'options' of undefined
rene
  • 41,474
  • 78
  • 114
  • 152
Paris
  • 6,323
  • 7
  • 31
  • 49
  • You may want to look at http://stackoverflow.com/questions/1930305/jquery-remove-call-in-callback-triggers-infinite-loop, but I am not positive your question is a duplicate of this other question. – James Black Apr 20 '11 at 23:35

0 Answers0