jQuery嵌套可排序-在所有可用的UL中移动LI元素 [英] jQuery Nested Sortable - Move LI elements within all available UL's
问题描述
我有以下代码可以运行,尽管我感觉它运行得很慢.我想做的是允许<li>
在现有的<ul>
下自由移动或将其上移.我还希望能够创建层次结构,因此如果将<li>
拖动到另一个将创建层次结构的<li>
下.我认为从这种意义上讲,我将不得不在每个<li>
下绘制一个<ul>
,以防万一.我只想将其限制为2或3级.
I have the following code which works although it runs quite slowly I feel. What I want to do is allow <li>
's to be moved freely under existing <ul>
's or move them up a level. I also want to be able to create hierarchies so if you dragged a <li>
under another <li>
that would create a hierarchy. I think in that sense I would have to render a <ul>
under each <li>
just in case. I only want to limit it to 2 or 3 levels deep.
$("#sort_list").sortable({
containment: 'parent',
axis: 'y',
revert: true,
opacity: 0.8
});
$(".sub_list").sortable({
containment: 'parent',
axis: 'y',
revert: true,
opacity: 0.8,
});
$("#sort_list").disableSelection();
<ul id="sort_list">
<li>one</li>
<li>two
<ul class="sub_list">
<li>sub one</li>
<li>sub two</li>
</ul>
</li>
<li>three</li>
<li>four</li>
</ul>
推荐答案
一个很好的答案是
https://github.com/ilikenwf/nestedSortable
我很高兴我找到了它. jstree对我来说太重了.
i am glad that I have found it. jstree was too heavyweight for me.
这篇关于jQuery嵌套可排序-在所有可用的UL中移动LI元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!