我有一个带有特殊 ID 的父 div,我正在对其子元素进行排序。这些 child 也有可分类的 child ,我也会让这些 child 有可分类的元素。所以我的可排序嵌套分为三个级别
<div id="sortableGrandParent">
<div id="sortableParent1">SomeTitle1
<div id="sortableChild11">I want these to only</div>
<div id="sortableChild21">sort between themselves</div>
</div>
<div id="sortableParent2">SomeTitle2
<div id="sortableChild21">And not jump to here</div>
</div>
</div>
我用
发起这一切 jQuery(function () {
jQuery("#sortableGrandParent, #sortableParent1, #sortableParent2").sortable({ ...
而且它有效。我可以对 child 和 parent 进行排序,我什至设法找到一种方法将它们分别保存在数据库中。 问题是我将 sortableParent2 的子级与 sortableParent1 的子级放在一起,尽管我无法将其保存到数据库中,因为 ID 不匹配,但它的计数器用户友好,如果可能的话,我希望每个 DIV 的 children 只能在自己之间进行排序。
我很确定我需要以某种方式使用 connectWith 并获得一些混合 N' 匹配的情况,但我完全不确定如何做?
最佳答案
正如评论中提到的:
这正是使用 items
和 connectWith
默认值得到的行为
jQuery("#sortableGrandParent, #sortableParent1, #sortableParent2").sortable({
items: ">*",
connectWith: false
});
fiddle :http://jsfiddle.net/tnx8jrqs/
关于javascript - 禁止嵌套排序混合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40105075/