Search code examples
jqueryjquery-uijquery-ui-droppable

jquery ui droppable doesn't do anything


I can't seem to get my droppable working. When I take my .item and move it over to the .itembox it doesn't trigger anything, tho I don't do anything wrong (I guess). It's an assignment for school and I need to get it fixed by the morning. Help would be greatly appreciated.

$(".item").draggable();
$(".itembox").droppable({
    tolerance: "touch",
    drop: function() {
        console.log("hello");
    }
});

Solution

  • you need to add

     accept: 'div.item',
     drop: dropfunction
    

    , to your droppable where dropfunction is somekind of function to be triggered on drop

    I'm working on a little game where i'm using drag and drop, you can take a look at my handleTileDrop function for more details

    I hope this helps, good luck with your project :)