2015-10-16 26 views
0

我试图用jsTree上的ajax加载子节点。我可以使用回调方法加载点击节点的子节点。不过,我想在回调中加载多个级别。jsTree在ajax调用中加载子元素的子元素

实施例:

  [{"text" : "Child 2", "id" : "2", "children" : true}, 
      {"text" : "Child 3", "id" : "3", "children" : true}, 
      {"text" : "Parent 4", "id" : "4", "children" : true}, 
      {"text" : "Child 5", "id" : "5", "parent": "4", "children" : true}] 

作为似乎有欲加载嵌套节点。这似乎不可能。我创造了一个小提琴来说明。基于利维乌斯答案

jsfiddle

+0

你需要给它的数据为您的孩子http://jsfiddle.net/2kwkh2uL/2715/ –

+0

@LiviuBoboia工程。所以我认为没有办法使用父子结构。 –

回答

0

  [{"text" : "Child 2", "id" : "2", "children" :[{"text" : "Grand Child 2", "id" : "12"}]}, 
      {"text" : "Child 3", "id" : "3", "children" :[{"text" : "Grand Child 3", "id" : "13"}]}, 
      {"text" : "Parent 4", "id" : "4", "children" :[{"text" : "Grand Child 4", "id" : "14"}]}, 
      {"text" : "Child 5", "id" : "5", "children" :[{"text" : "Grand Child 5", "id" : "15"}]}] 

它工作时,我们使用了嵌套子结构不是父子ID结构(如命名上jsTree.com替代结构)。

Working Fiddle