Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle moving between nested list #89

Open
morganpizzini opened this issue Oct 26, 2017 · 3 comments
Open

Handle moving between nested list #89

morganpizzini opened this issue Oct 26, 2017 · 3 comments

Comments

@morganpizzini
Copy link

Expected behavior

In the following template i want to move nested items by keeping depth level.

item
- sub-item
- sub-item
item
- sub-item
- sub-item

Actual behavior

when i start dragging sub-item i can drop at item level.

How i Solved

as this link says
I added the part

var itemMoveIn = this.dragEl.find(opt.itemNodeName).data('moveIn');
var listNo = this.pointEl.closest('.dd-list').data('listNo');
if (itemMoveIn !== listNo) {
 return;
}

and use data-list-no and data-move-in for define the "range of motion".
now my template is

<ol class="dd-list" data-list-no="1">
      <li class="dd-item schedule" data-move-in="1">
           <ol class="dd-list" data-list-no="2">
                 <li class="dd-item schedule" data-move-in="2"></li>
                 <li class="dd-item schedule" data-move-in="2"></li>
          </ol>
    </li>
     <li class="dd-item schedule" data-move-in="1">
           <ol class="dd-list" data-list-no="2">
                 <li class="dd-item schedule" data-move-in="2"></li>
                 <li class="dd-item schedule" data-move-in="2"></li>
          </ol>
    </li>
</ol>

sub-item now can be dropped only when list have data-list-no="2"

@RomanBurunkov
Copy link
Contributor

Hi,

It looks like you have used some solution from original nestable.

In nestable 2 you can just use 'beforeDragStop'.
It is described in the ReadMe.

@morganpizzini
Copy link
Author

Understood, but i use the same model in various pages, and in all of them i have to rewrite 'beforeDragStop' callback, now why 3 rows in plug-in code I can handle it without care about it anymore.
mine was just a hint since it was very useful and I can handle the page behavior by html without worrying about the javascript. 😄

@pjona
Copy link
Collaborator

pjona commented Oct 26, 2017

@morganpizzini Can you make pull request with this changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants