Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jsTree-在loaded.jsTree事件上获取所选节点_Javascript_Jquery_Jstree - Fatal编程技术网

Javascript jsTree-在loaded.jsTree事件上获取所选节点

Javascript jsTree-在loaded.jsTree事件上获取所选节点,javascript,jquery,jstree,Javascript,Jquery,Jstree,如何在loaded.jstree事件中获取所选节点 我应该在事件处理程序中执行什么操作: $('#Tree').bind('loaded.jstree', function(event, data){//TODO: How to get the selected node here?}).jstree(); 顺便说一下,我发现事件数据arg对象包含一个名为get_selected()的函数,但无法从中获取任何内容 我的目的是将客户端重定向到当前选定的节点(通过“url”属性) 提前感谢

如何在loaded.jstree事件中获取所选节点

我应该在事件处理程序中执行什么操作:

    $('#Tree').bind('loaded.jstree', function(event, data){//TODO: How to get the selected node here?}).jstree();
顺便说一下,我发现事件数据arg对象包含一个名为get_selected()的函数,但无法从中获取任何内容

我的目的是将客户端重定向到当前选定的节点(通过“url”属性)


提前感谢

根据此处演示的文档:

你可以做:

.one("reselect.jstree", function (event, data) { });

仔细阅读以下文档:

使用一个,这是因为如果调用
refresh
,则这些事件是 触发


对于最后一个事件
委托
,而不是写入
事件.preventDefault()
,如果不使用UI插件,可以正确重定向,并写入:
window.location=$(this.attr('href')

您可以通过以下方式选择当前节点:

$('#' + data.node.id)
代码变为:

$('#Tree').bind('loaded.jstree', function(event, data){
console.log($('#' + data.node.id)); //This is current node, see on console
}).jstree();

您不想使用“select_node.jstree”事件来执行此操作吗?您好,您有任何参考或代码示例吗?
$('#' + data.node.id)
$('#Tree').bind('loaded.jstree', function(event, data){
console.log($('#' + data.node.id)); //This is current node, see on console
}).jstree();