开发者

How to remove a cloned draggable which has been dropped into a container?

I created a widget builder app where you can drag widgets (draggables) onto a widget builder (droppable). Multiple widgets (clones) can be dragged onto the builder, the clones are draggable, and the clones are constrained within the builder.

I have provided a small box in the upper right corner of the widget builder where I would like to use it as开发者_开发百科 a trash can (of sorts; to remove the clone if dragged onto it).

Can someone help me with creating the ability to remove a clone if the clone is dragged onto the trash area?

Here is my example: http://jsfiddle.net/mitchslap/K8VKa/

Thank you thank you thank you!


Set 'greedy' param to 'true' in drop function in your droppable container:

$("#trashWidget").droppable({
    greedy: 'true',
    accept: function() { return true; },
    drop: function () { tolerance: 'fit', alert("Dropped!"); }
});

I've just tested this function and it seems to work flawlessly :)

Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜