如何为每个嵌套孩子存储所有父母的参考? [英] How to store reference of all parents for each of the nested child?

查看:93
本文介绍了如何为每个嵌套孩子存储所有父母的参考?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

小提琴:

解决方案

使用此条件分配父对象:

obj.parent = data.parent ||null;

Fiddle : http://jsfiddle.net/p35cobgx/3/

Below is my tree structure :

Node
   Node-1
     Node-1-1......

Now I want to store back reference of all parents for each of the nodes like below :

Node

Node-1 (should store back reference of only Node because this is last parent for Node-1)

Node-1-1(should store back reference of all parents i.e Node-1 and Node because Node is the last parent for Node-1-1).

But problem with my code is i am unable to store reference of Node for Node-1-1.

解决方案

Use this condition for assigning the parent:

obj.parent = data.parent || null;

这篇关于如何为每个嵌套孩子存储所有父母的参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆