2

OK, I'm probably missing something obvious here, but my searches aren't turning up anything helpful. I've set up a sortable list and connected a draggable "palette list" to it, as explained here: http://jqueryui.com/demos/draggable/#sortable

I can drag items from my draggable list and drop them on my sortable list. That works fine.

I need to fire a function only when one of these items is dropped onto the sortable.

I've tried the "stop" hook on the draggable item, but that fires regardless of where the item is dropped (it fires if revert: 'invalid' is triggered, for example). I can't find any properties anywhere to tell me whether the drag was successful or not.

I've tried treating the sortable as a "droppable" and binding to "drop", but that doesn't even get called.

Thanks for the help!

Tim Ridgely
  • 2,400
  • 1
  • 18
  • 25

1 Answers1

3

Found it!

Sortable has an event called receive. http://api.jqueryui.com/sortable/#event-receive

How I missed this in the past few hours of digging is beyond me.

Tim Ridgely
  • 2,400
  • 1
  • 18
  • 25
  • 1
    The receive function is called even if you're not dropping the item. Then when you drag/drop an item in your sortable list the receive method is called with the original dragged item which is incorrect. So: drag item to sortable list, but don't drop it. Put the item back. (receive is not called) Now drag an item within your sortable list and receive is called. –  Jul 11 '14 at 13:05