【问题标题】:How to get full path of selected node in jstree?(root node to selected node)如何在jstree中获取选定节点的完整路径?(根节点到选定节点)
【发布时间】:2014-08-20 13:59:42
【问题描述】:

我想建立一个目录管理系统,用户可以在其中创建、重命名、删除目录并将文件保存在目录中。为此,我正在使用 jquery jstree。

my jsTree is like:-

*A(root node)
  *b
  *C
    *D

我想在按钮单击时获取所选节点的完整路径。如果用户选择*D 文件夹,则路径应为"A/C/d",如果用户选择C,则路径应为"A/C"。 任何帮助建议将不胜感激

【问题讨论】:

  • 我见过这个问题,但我不知道什么是 bind() 事件。我需要在按钮单击时获取完整路径。我绑定使用 var ids = data.inst.get_path('#' + data.rslt.obj.attr('id'),true);但不知道那里的“数据”是什么。
  • 我是 jsTree 的新手 :(
  • bind 与 jsTree 无关,它是 jQuery。如果您需要更多帮助,请添加您的 jsTree 的工作演示

标签: jquery jstree


【解决方案1】:

我用过这个:

.on('changed.jstree', function (e, data) {
  var path = data.instance.get_path(data.node,'/');
  console.log('Selected: ' + path); 
})

【讨论】:

    【解决方案2】:

    你可以简单地找到它

    $('#drives_tree').jstree().get_path($('#drives_tree').jstree("get_selected", true)[0], ' > ')

    这里的drives_tree是我的jstree的id

    【讨论】:

      猜你喜欢
      • 2012-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多