SpaceTree如何在节点点击上添加子树

时间:2012-12-18 14:27:27

标签: javascript ruby-on-rails infovis thejit space-tree

我编写了以下代码,显示错误:

Cannot read property 'children' of null

我希望在单击节点时加载子项。

request:function(nodeId, level, onComplete)
            {
                alert(nodeId+'p   '+level+' p  '+onComplete);
                var i=0;
              $.ajax({
                    url: '/users/userhierarchy.json?id=' + nodeId,
                   dataType: 'json',
                   success: function(json){
                        var tree = json;
                        var subtree = $jit.json.getSubtree(tree, nodeId);

                        $jit.json.prune(subtree, level);
                        i++;
                        ans= {
                            'id': nodeId,
                            'children': subtree.children
                        };
                        onComplete.onComplete(nodeId, ans);

                    },

                });

            }

0 个答案:

没有答案