Search code examples
jquery-uidrag-and-dropdraggableoutjquery-ui-droppable

Jquery UI Droppable Out function


I would like to trigger an event when I am leaving the droppable element, so I plan to use the out function. But I have two droppable elements. When I wrote the code for one element it works but not for two.

Html :

<div id="source">
  <item1>
  ...
  <itemx>
</div>
<div id="drop1"></div>
<div id="drop2"></div>

Jquery:

$("div#drop1, div#drop2").droppable ({
  drop : function (event, ui) {
     $(this).append (ui.draggable);
     alert("Hello!");
  },

  out : function (event, ui) {
    alert("Goodbye");    
  },
});

But the Out function doesn't trigger ? I could write it twice but if I have 20 droppable elements, it's not the solution. Any ideas ? Thanks !


Solution

  • you have an error on line 9 ... but its working for me without this... check this fiddle:

    http://jsfiddle.net/yCeL3/