jQuery Ui可排序不能在克隆的ul中拖动li元素 [英] jQuery Ui sortable can`t drag li elements in cloned ul

查看:125
本文介绍了jQuery Ui可排序不能在克隆的ul中拖动li元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对jQuery可排序列表有疑问.我有两个ul列表.这两个列表是可排序的(完整的ul集),li子代也是可排序的.因此,您可以对完整的列表位置进行排序,还可以对li位置进行排序,并将li元素从一个列表拖动到另一个列表.

i have a problem with a jQuery sortable list. I got two ul-lists. These two lists are sortable (the complete ul-sets) and the li children are sortable also. So you can sort the complete list position and you can sort the li-positions and drag li-elements from one list to another.

使用每个列表旁边的按钮,我可以克隆一个完整的ul-list.因此,我使用clone(true,true)函数.我使用真实的参数,因为我在按钮上得到了事件,并且希望将它们应用于克隆.我还希望将可排序函数应用于克隆.

Using a button next to each list, i can clone a complete ul-list. Therefore i use the clone(true,true) function. I use true parameters, because i got events on the buttons and i want them to be applied to the clones. I also want the sortable function to be applied to the clone.

问题:

++++++++++++++++++++++++++++++++++++++

+++++++++++++++++++++++++++++++++++++

当我仅使用clone()克隆元素时:

When i only use clone() to clone the element:

您不能将li元素从ul>克隆拖到另一个列表中, 您不能使用clone-button(按钮两次克隆一个克隆的元素 动作迷路了.

You cant drag the li Elements from the ul>-clone to another list and you can`t clone a cloned element twice with the clone-button (button action got lost).

当我使用clone(true)clone(true,true)克隆元素时:

When i use clone(true) or clone(true,true) to clone the element:

您可以将元素从ul克隆中拖动到另一个列表,但不能将元素从其他列表中拖动到ul克隆中.

You can drag li-elements from the ul-clone to another list, but you can`t drag li-elements from other lists to the ul-clone.

您可以在这里尝试:

http://jsfiddle.net/uKEJL/133/

有什么想法吗?

-Thx Tobi-

-Thx Tobi-

推荐答案

您的问题与绑定有关.事件回调绑定到当前的窗口小部件对象.比较

Your problem has to do with bindings. The event callbacks get bound to the current widget object. Compare

https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.mouse.js#L31-L41

如果克隆列表,则jQuery会正确触发该事件,但回调将绑定到原始列表.

If you clone the lists, the event gets fired correctly by jQuery, but the callback is bound to the original list.

您将必须在每个克隆上初始化可排序的序列.

You will have to initialize sortable on every clone.

这篇关于jQuery Ui可排序不能在克隆的ul中拖动li元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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