如何在可嵌套列表的相同深度之间移动列表项 [英] How to move list-items between same depth for nestable list

查看:60
本文介绍了如何在可嵌套列表的相同深度之间移动列表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 https://github.com/RamonSmit/Nestable 用于拖放列表订购清单中的项目.

I am using https://github.com/RamonSmit/Nestable for drag n drop list items within the ordered-list.

我从以下位置获取了js和CSS:-

I have taken js and css from:-

https://cdnjs.cloudflare.com/ajax/libs/nestable2/1.5.0/jquery.nestable.css https://cdnjs.cloudflare.com/ajax/libs/nestable2/1.5.0/jquery.nestable.js

以下是我创建的有序列表:-

Following is the ordered list that I have created:-

<div class="dd">
            <ol class="dd-list">
                <li class="dd-item" data-id="1" data-type="Chapter">
                    <div class="dd-handle">Item 1</div>
                </li>
                <li class="dd-item" data-id="2" data-type="Chapter">
                    <div class="dd-handle">Item 2</div>
                </li>
                <li class="dd-item" data-id="3"data-type="Chapter">
                    <div class="dd-handle">Item 3</div>
                    <ol class="dd-list">
                        <li class="dd-item" data-id="4" data-type="Title">
                            <div class="dd-handle">Item 4</div>
                        </li>
                        <li class="dd-item" data-id="5" data-type="Title">
                            <div class="dd-handle">Item 5</div>
                        </li>
                    </ol>
                </li>
            </ol>
        </div>

$('.dd').nestable({ maxDepth:2 });

$('.dd').nestable({ maxDepth: 2 });

我只需要两个级别的深度即可.在第一层深度,我将有父母,在第二层深度,我将需要标题.现在,我需要将标题标题从一个章节拖到另一章,但是我需要停止将章节拖到另一章中.这样,在拖动n拖放后,我可以将标题保留为标题,将章节保留为章节.

I required only two levels for depth. At first level of depth I will have parents and at second level of depth I required titles. Now I required to drag n drop title from one chapter to another but I required to stop chapters to be dragged within another chapter. So that I can retain the title as title and chapter as chapter after drag n drop.

我尝试了很多使用可嵌套方法的hit-n-trials,但无法弄清楚.如果有人可以帮助我.

I tried lot of hit-n-trials along with nestable methods but could not figure it out. If anybody can help me out.

推荐答案

我们能否获得将要删除的列表项的深度.同样,如果我们能够获得目的地的深度,那也是可以的.这样,我们可以检查两个深度是否相同.如果相同,我们将以其他方式允许放置,否则将返回false.

Can we get the depth of list-item which is going to be dropped. Also somehow if we can get the depth of destination. This way we can check if both depth(s) are same or not. If same we will allow drop other wise we will return false.

这篇关于如何在可嵌套列表的相同深度之间移动列表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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