2011-08-05 43 views
0

乾草反應我使用此代碼克隆拖動元素克隆「拖動」元素的不爲「可棄」區域

$('.draggable').draggable({helper: "clone"}); 
$('.draggable').bind('dragstop', function(event, ui) { 
    $(this).after($(ui.helper).clone().draggable()); 
}); 


$(".droppable").droppable({accept: ".draggable"}); 

偉大的工程。但是,「克隆」對象不會對「可丟棄」區域產生長時間反應。

有沒有辦法解決這個問題?我可以讓draggable住嗎?因此,任何新的.draggable元素都會與可丟棄的元素髮生反應?

回答

0

你要申報drop -event的函數,在投擲的互動缺失helper:'clone'

看到Here

每一個克隆與可投放交互。

$('.draggable').draggable({helper: "clone"}); 
$('.draggable').bind('dragstop', function(event, ui) { 
    $(this).after($(ui.helper).clone().draggable()); 
}); 


$(".droppable").droppable({accept: ".draggable", 


     drop: function(event, ui) { 
      $(this) 
       .addClass("dropped").find("> p") 
        .html(document.lastModified);; 
     } 

}); 
0

嘗試這樣

$('.draggable').draggable({helper: "clone"}); 

$('.draggable').bind('dragstop', function(event, ui) { 
    $(this).after($(ui.helper).clone().draggable()); 


    //re-make objects draggable 
    $('.draggable').draggable({helper: "clone"}); 
}); 
...