0

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

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

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.

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

4

1 回答 1

0

我们能得到将要被删除的列表项的深度吗?如果我们能得到目的地的深度,也不知何故。这样我们可以检查两个深度是否相同。如果相同,我们将允许丢弃,否则我们将返回 false。

于 2017-10-04T03:23:21.610 回答