jsTree: Prevent before and after TYPE, only use inside

Posted by Nic Hubbard on Stack Overflow See other posts from Stack Overflow or by Nic Hubbard
Published on 2010-03-15T05:39:54Z Indexed on 2010/03/15 5:49 UTC
Read the original article Hit count: 285

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about jstree

Related posts about JavaScript