jsTree : Append child node dynamically

狂风中的少年 提交于 2020-01-04 12:39:10

问题


I am using below code while page load to generate a tree using jsTree.

  $('#jstree_demo_div').jstree({
          'core': {
             'themes': {
                        'name': 'proton',
                        'responsive': true
                        },
             'data': results,
             "check_callback" : true
          }
  });

All is working fine and results array is showing as tree.I want to add /append dynamically child nodes while clicking on few of the nodes in this static tree.

Please help.


回答1:


If you set the children property of a particular node to true then the node is rendered as closed, and when the node is expanded then core.data.data and core.data.url functions are called (this is assuming you are using AJAX).

See the docs for using AJAX http://www.jstree.com/docs/json/

Alternatively you can supply a function for core.data which is what is called to load the tree, and any nodes.




回答2:


If you read the jsTree API, you can make use of these below.

get_children_dom (obj)

draw_children(node)private

Learn how to fetch a single child node and draw it.



来源:https://stackoverflow.com/questions/29301155/jstree-append-child-node-dynamically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!