vakata/jstree — Issue #130: Duplicated items on second level after move.
Author: richardnap
Created: 2011-11-21 10:10:29+00:00
State: open

Dear Ivan,

I have implemented jstree in a new CMS I am developing, using it to provide a user to edit the menu order of a Three level menuItem tree. It was pretty easy to implement, I also implemented the contextmenu wich was very easy.
So I am almost done but got stuck on a bug.

Whenever I move an item on the second level of the tree, it gets duplicated in that branch. And the feedback I use to determine what item was moved , and the item id of the item that was previously in it's place are not giving the right values.

For example.

On the first level my feedback looks like this:
[data.rslt.o ] Node beeing moved: id: phtml_2 myPath: 0 myMenuOrder: 4
[data.rslt.cp] calculated position to move to (always a number): 5
[data.rslt.r ] the reference node in the move: id: phtml_61 myPath: 0 myMenuOrder: 5
[data.rslt.np] the new parent: id: mainTreeContainer myPath: undefined myMenuOrder: undefined
[data.rslt.op] the former parent: mainTreeContainer myPath: undefined myMenuOrder: undefined
[data.rslt.or] the node that was previously in the position of the moved node: id: undefined myPath: undefined myMenuOrder: undefined
[data.rslt.p ] direction: after [the position to move to (may be a string - after/before last/first, etc)]

this is OK.
(I will use these parameters to call my serverside script to update the database)
But when I move an item on the second level:

[data.rslt.o ] Node beeing moved: id: phtml_112 myPath: 3 myMenuOrder: 2
[data.rslt.cp] calculated position to move to (always a number): 0
[data.rslt.r ] the reference node in the move: id: phtml_103 myPath: 3 myMenuOrder: 1
[data.rslt.np] the new parent: id: phtml_6 myPath: 0 myMenuOrder: 3
[data.rslt.op] the former parent: phtml_6 myPath: 0 myMenuOrder: 3
[data.rslt.or] the node that was previously in the position of the moved node: id: phtml_103 myPath: 3 myMenuOrder: 1

As you can see the CP (calculated position) is zero. And the menuItem that was moved was also duplicated.

Do you have any idea if this is a genuine BUG or am I doing something wrong?
I hope you can help me. Thnax for a great jQuery plugin, keep up the good work.

Kind Regards,

Richard Nap