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

Bug: Insertion of duplicate items when trying to use 'add' with parent_id #84

Closed
rkhom opened this issue Oct 6, 2017 · 2 comments
Closed
Labels

Comments

@rkhom
Copy link

rkhom commented Oct 6, 2017

Hi! There is a bug in Add function. When we try to add new item with setting parent_id, where parent item is non-leaf element, a new item appends to the parent item and to each its descendant.
For example, there is a code from your Demo-page:
https://jsfiddle.net/RomanKhomyshynets/4vogfw6o/1/
When we bind for "Add new item" button such actions
if(action === 'add-item') { var newItem = { "id": ++lastId, "content": "New Item " + lastId, "parent_id":2 }; $('#nestable').nestable('add', newItem); }
Nestable inserts "New item 13" two times - as a child of Item 2 and child of Item 5.

@rkhom
Copy link
Author

rkhom commented Oct 6, 2017

The problem is in row 244 of current version jquery.nestable.js
The solution is to change its code from tree = tree.find(listClassSelector);
onto
tree = tree.find(listClassSelector+':first');

@pjona pjona added the bug label Oct 22, 2017
@pjona pjona closed this as completed in ba1cedf Oct 22, 2017
@pjona
Copy link
Collaborator

pjona commented Oct 22, 2017

@RomanKhomyshynets Thanks, great job!

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

No branches or pull requests

2 participants