views:

29

answers:

2

Hey there,

I'm making an app, that is using one droppable div and a few draggable divs. How can I make the droppable to not accept more than one draggable div? I Googled, but didn't find any workaround.

+2  A: 

You can destroy the .droppable() widget after the first drop, like this:

$(".droppable").droppable({
    drop: function( event, ui ) {
        $(this).droppable("destroy");
    }
});

You can try out a demo here.

Nick Craver
ok, but when I free this droppable field, how to make it droppable again
Emil Avramov
@Emil - You can use `"disable"` then `"enable"` later instead of `"destroy"` if you need to re-enable it :)
Nick Craver
i did it, but i dont know how to enable it. I tried with out: enable_Droppable, but it didn't work. What should I use instead of 'out'
Emil Avramov
A: 

A workaround came up in mi mind. How can i check is there's dropped element in this droppable div? If it's busy then revert this draggable, which is trying to be dropped

Emil Avramov