jQuery UI:可排序和可拖动+可排序和可拖放 [英] jQuery UI: sortable and draggable + sortable and droppable

查看:162
本文介绍了jQuery UI:可排序和可拖动+可排序和可拖放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个列表.它们是可排序的,但没有连接(列表"one"的元素不能与列表"two"的元素混合)

I have two lists. They are sortable but not connected (elements of list "one" cannot be mixed with elements of list "two")

我希望将列表"one"的元素拖放到列表"two"中,因为我想将列表"two"的元素拖放到列表"one"中.

I want elements of list "one" be droppable and elements of list "two" be draggable, because I want to drag and drop element of list "two" into list "one".

我应该怎么办?

我试图使问题尽可能笼统,但也许我应该更清楚...对不起. 列表一的元素是类别",它们应该是可排序的. 清单2的元素是链接",应可排序. 链接仅属于一个类别. 我想将链接从类别移动到另一个,并且我想使用JQuery Ui.

I tried to make the question as general as possible but maybe I should be more clear... sorry. Elements of list one are "categories" and they should be sortable. Elements of list two are "links" and should be sortable. A link belongs to only one category. I want to move a link from a categerory to another and I would love to use JQuery Ui.

推荐答案

如果我正确理解了您的问题,则不必将draggabledroppablesortable结合使用.

If I understand your question correctly, you do not have to use draggable and droppable in conjunction with sortable in your case.

可稳定的连接本质上是单向的,因此您只需要将第二个列表连接到第一个列表,而不必将第一个列表连接到第二个列表:

Sortable connections are inherently one-way, so you only have to connect the second list to the first, and avoid connecting the first to the second:

<ul id="first">
    <!-- ... -->
</ul>

<ul id="second">
    <!-- ... -->
</ul>


$("#first").sortable();
$("#second").sortable({
    connectWith: "#first"
});

这篇关于jQuery UI:可排序和可拖动+可排序和可拖放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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