我有两个关于 jsTree 的问题:
我正在使用 JSON 和 struts2 生成一个 jsTree。第一次正确显示树。但是在单击按钮时,我想将具有不同数据的树重新加载到同一个 div 中。在单击按钮时,我给出了与第一次生成 jstree 时相同的操作名称。
如果我单击树的任何节点,那么我需要该节点的 ID,如果该节点有任何父节点,则还需要该节点的父节点 ID,父节点有父节点,然后是该节点的 ID父节点也是
例子
Parent 1
|__Parent 2
|__Child 1
我正在点击 Child 1,然后我想要 Child 1、Parent 2、Parent 1 等的 ID。
最佳答案
我不确定你是否真的浏览过文档,但这里有一些可以帮助你的东西:
对于你的第一个问题,你可以使用回滚:http://luban.danse.us/jazzclub/javascripts/jquery/jsTree/reference/_examples/5_others.html 刷新也可以是一个选项:http://luban.danse.us/jazzclub/javascripts/jquery/jsTree/reference/_examples/2_operations.html
对于你的第二个问题,你可以使用回调:http://luban.danse.us/jazzclub/javascripts/jquery/jsTree/reference/_examples/3_callbacks.html
._get_parent
也会帮助你:
._get_parent ( node )
Gets the LI element representing the parent of the passed node. Returns false on failure. mixed node
This can be a DOM node, jQuery node or selector pointing to an element within the tree, whose parent we want.
有关详细信息,请参阅完整文档:http://www.jstree.com/documentation/core
关于javascript - jsTree加载并点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8120617/