jQuery draggable获取其内容JS被触发两次 [英] jquery draggable get its content JS fired twice

查看:107
本文介绍了jQuery draggable获取其内容JS被触发两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到您是第一次拖动它,然后取消拖动,被拖动项目中的js会再次触发,之后,一切似乎都正常了,知道吗?

I noticed the first time you drag it around and then cancel the dragging, the js in the dragged item will fire another time, after that, everything seems normal, any idea?

推荐答案

我在jquery ui论坛上找到了答案!

I found the answer on the jquery ui forum!

update触发两次,因为正在更新2个列表(原始列表及其移动到的列表).因此,您可以选择receive:选项,也可以在更新中添加:此检查:

update is firing twice because 2 lists are being update (the original, and the list it moves to). so, you can either you the receive: option or in your update you can add: this check:

if (this === ui.item.parent()[0]) {
    //do your stuff here
}

这是jquery论坛上的线程: http://forum.jquery.com/topic/sortables-update-回调并连接

here's the thread on the jquery forum: http://forum.jquery.com/topic/sortables-update-callback-and-connectwith

这篇关于jQuery draggable获取其内容JS被触发两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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