JQuery Draggable + Sortable: How to tell if item was actually added to my sortable list?

狂风中的少年 提交于 2019-12-20 05:36:06

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/3257925/jquery-draggable-sortable-how-to-tell-if-item-was-actually-added-to-my-sortab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!