Programmatically adding child nodes to a jstree

前端 未结 2 646
不知归路
不知归路 2021-02-19 15:01

I\'m trying to write some code that adds nodes to a jstree dynamically. I\'ve followed the doc at http://www.jstree.com/documentation/crrm but can\'t get a simple example to wor

2条回答
  •  滥情空心
    2021-02-19 15:22

    When using periods in ID's you need to escape them like so:

    $("#tree").jstree("create", $("#child1\\.id"), "inside",  { "data" : "child2" },
                              function() { alert("added"); }, true);
    

    This is because of how it uses jQuery selectors. It is mentioned in the jsTree FAQ located here: http://www.jstree.com/faq/

提交回复
热议问题