JQuery Draggable + Sortable:如何判断项目是否实际添加到我的可排序列表中? [英] JQuery Draggable + Sortable: How to tell if item was actually added to my sortable list?

查看:24
本文介绍了JQuery Draggable + Sortable:如何判断项目是否实际添加到我的可排序列表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我可能在这里遗漏了一些明显的东西,但我的搜索没有找到任何有用的东西.我已经设置了一个可排序列表并将一个可拖动的调色板列表"连接到它,如下所述:http://jqueryui.com/demos/draggable/#sortable

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.

我已经在可拖动项目上尝试了停止"钩子,但无论项目被放置在哪里都会触发(例如,如果触发了revert: 'invalid'",它就会触发).我在任何地方都找不到任何属性来告诉我拖动是否成功.

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.

我尝试将 sortable 视为droppable"并绑定到drop",但它甚至没有被调用.

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

感谢您的帮助!

推荐答案

找到了!

Sortable 有一个称为receive 的事件.http://api.jqueryui.com/sortable/#event-receive

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.

这篇关于JQuery Draggable + Sortable:如何判断项目是否实际添加到我的可排序列表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆