I am using jsTree which is very nice. When dragging and dropping, I don't really care for the before and after types, I only want to use inside. Meaning, I am only concerned about that parent that a child is dropped into, rather than where the order is with other elements INSIDE the parent.
So, I wanted to build my callback, so it always refers to the parent node that it is inside. But, it is not fool proof, yet.
onmove : function (NODE,REF_NODE,TYPE,TREE_OBJ,RB) {
if (TYPE == 'inside') {
alert('Item to move:'+$(NODE).attr('rel')+' to '+$(REF_NODE).attr('rel')+' '+TYPE);
} else if (TYPE == 'after') {
alert('Item to move:'+$(NODE).attr('rel')+' to '+$(REF_NODE).parent().parent('li').attr('rel')+' '+TYPE);
}
},
Does anyone have suggestions, how I can change my callback, so that the REF_NODE is always the parent that the NODE is moved into? Rather than a sibling of, which is a child of the parent?
Here is an example on jsbin: http://jsbin.com/uroye3/2
When trying the example, drag other folders onto the Templates folder. You SHOULD be alerted that you are moving the other folders into folder 4. But, if you try different before and after drags into the Templates folder, you sometimes get undefined. So, the results are not always as expected. Like I said, I just always want to know the parent folder, in this case 4, that another folder is dropped into.