how to access old parent of node in move_node.jstree event

1,617 views
Skip to first unread message

Janusz

unread,
Jul 7, 2010, 12:08:32 PM7/7/10
to jsTree
Hi,

I have code:

...
.bind("move_node.jstree", OnMoveNode)
...

function OnMoveNode(event, data)
{
var treeInstance = data.inst;
var node = data.rslt.o;
var parentNode = treeInstance._get_parent(node);

var oldParentNode = ??????
}

How can I access old parent of moving node?


Thanks in advance
Janusz

vakata

unread,
Jul 7, 2010, 12:59:07 PM7/7/10
to jsTree
Try data.rslt.op

Kindest regards,
Ivan

Janusz

unread,
Jul 9, 2010, 7:55:35 AM7/9/10
to jsTree
Thanks Ivan, it works!!
How do the same (access parent) in delete_node.jstree handler
function?

Code below returns -1 value as parent
var parentNode = data.inst._get_parent(data.args[0]);



On 7 Lip, 18:59, vakata <ivan.bozha...@gmail.com> wrote:
> Try data.rslt.op
>
> Kindest regards,
> Ivan
>
> On 7 Юли, 19:08,Janusz<janusz.noszczyn...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I have code:
>
> > ...
> > .bind("move_node.jstree", OnMoveNode)
> > ...
>
> > function OnMoveNode(event, data)
> > {
> >    var treeInstance = data.inst;
> >    var node = data.rslt.o;
> >    var parentNode = treeInstance._get_parent(node);
>
> >    var oldParentNode = ??????
>
> > }
>
> > How can I access old parent of moving node?
>
> > Thanks in advance
> >Janusz- Ukryj cytowany tekst -
>
> - Pokaż cytowany tekst -

vakata

unread,
Jul 9, 2010, 8:04:13 AM7/9/10
to jsTree
Sorry about that - for now all you can get is the previous node (which
may also be the parent):
data.rslt.prev

Anyway - I added data.rslt.parent to both "delete_node" and "remove",
but have not committed yet, so with the next commit you will be able
to simply use data.rslt.parent.

Kindest regards,
Ivan

Janusz

unread,
Jul 14, 2010, 9:43:21 AM7/14/10
to jsTree
Thanks Ivan!
When it will be commited?

Best regards
Janusz

On 9 Lip, 14:04, vakata <ivan.bozha...@gmail.com> wrote:
> Sorry about that - for now all you can get is the previous node (which
> may also be theparent):
> data.rslt.prev
>
> Anyway - I added data.rslt.parentto both "delete_node" and "remove",
> but have not committed yet, so with the next commit you will be able
> to simply use data.rslt.parent.
>
> Kindest regards,
> Ivan
>
> On 9 Юли, 14:55, Janusz <janusz.noszczyn...@gmail.com> wrote:
>
>
>
> > Thanks Ivan, it works!!
> > How do the same (accessparent) in delete_node.jstree handler
> > function?
>
> > Code below returns -1 value asparent
> > var parentNode = data.inst._get_parent(data.args[0]);
>
> > On 7 Lip, 18:59, vakata <ivan.bozha...@gmail.com> wrote:
>
> > > Try data.rslt.op
>
> > > Kindest regards,
> > > Ivan
>
> > > On 7 Юли, 19:08,Janusz<janusz.noszczyn...@gmail.com> wrote:
>
> > > > Hi,
>
> > > > I have code:
>
> > > > ...
> > > > .bind("move_node.jstree", OnMoveNode)
> > > > ...
>
> > > > function OnMoveNode(event, data)
> > > > {
> > > >    var treeInstance = data.inst;
> > > >    var node = data.rslt.o;
> > > >    var parentNode = treeInstance._get_parent(node);
>
> > > >    var oldParentNode = ??????
>
> > > > }
>
> > > > How can Iaccessoldparentof moving node?
>
> > > > Thanks in advance
> > > >Janusz- Ukryj cytowany tekst -
>
> > > - Pokaż cytowany tekst -- Ukryj cytowany tekst -

vakata

unread,
Jul 16, 2010, 10:25:52 AM7/16/10
to jsTree
Already is :)

Kindest regards,
Ivan

thequeue

unread,
Sep 4, 2010, 11:16:39 PM9/4/10
to jsTree
Hi there,

I'm trying to get the parent node by using "data.rslt.parent" from the
"delete_node" event, and it's returning 'undefined'. Am I missing
something?

.bind("delete_node.jstree", function (e, data)
{console.log(data.rslt.parent);})


Dan



On Jul 16, 10:25 am, vakata <ivan.bozha...@gmail.com> wrote:
> Already is :)
>
> Kindest regards,
> Ivan
>
> On Jul 14, 4:43 pm, Janusz <janusz.noszczyn...@gmail.com> wrote:
>
> > Thanks Ivan!
> > When it will be commited?
>
> > Best regards
> > Janusz
>
> > On 9 Lip, 14:04, vakata <ivan.bozha...@gmail.com> wrote:
>
> > > Sorry about that - for now all you can get is the previous node (which
> > > may also be theparent):
> > > data.rslt.prev
>
> > > Anyway - I added data.rslt.parentto both "delete_node" and "remove",
> > > but have not committed yet, so with the next commit you will be able
> > > to simply use data.rslt.parent.
>
> > > Kindest regards,
> > > Ivan
>
> > > On 9 Юли, 14:55, Janusz <janusz.noszczyn...@gmail.com> wrote:
>
> > > > Thanks Ivan, it works!!
> > > > How do the same (accessparent) indelete_node.jstree handler

vakata

unread,
Sep 17, 2010, 7:47:34 AM9/17/10
to jsTree
You should be using the latest commit to be able to do that (not the
download version)

Kindest regards,
Ivan

Michelle Site

unread,
Jun 30, 2015, 1:33:09 AM6/30/15
to jst...@googlegroups.com
hi! i have a problem with my code 
$("#data")
        .bind('move_node.jstree', function (e, data) {
          var node = data.rslt.o;
        });
Cannot read property 'o' of undefined.

am I missing something. Thanks 

Ivan Bozhanov

unread,
Jun 30, 2015, 8:07:23 AM6/30/15
to jst...@googlegroups.com, mariamich...@gmail.com
This is jstree version 1 code, if you are using version 3, this code will not work. To see what data contains - simply log it, or read the docs on the event:
http://www.jstree.com/api/#/?q=move_node&f=move_node.jstree

Best regards,
Ivan
Reply all
Reply to author
Forward
0 new messages