jQuery UI: sortable and draggable + sortable and droppable

僤鯓⒐⒋嵵緔 提交于 2020-01-05 08:02:34

问题


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

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".

How should I do?

EDIT:

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.


回答1:


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"
});


来源:https://stackoverflow.com/questions/11141723/jquery-ui-sortable-and-draggable-sortable-and-droppable

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