本文介绍了jstree jquery插件 - 获取父节点的所有子节点和子子节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
我正在使用 jsTree jquery 插件
我正在尝试获取选定父节点的所有节点和子节点.但不知何故,除非我使用递归,否则它不起作用.jsTree 有没有更好的方法?
I am trying to fetch all the nodes and sub nodes of a selected parent. But somehow it's not working unless I use recursion. Is there a better way inherent to jsTree?
推荐答案
我找到了一种方法.就我而言,我使用 xml 作为树的数据源.我通过以下方式将 open_node 事件绑定到 jstree.请注意,即使我使用的是 xml,内部结构也是 html 数据的结构.
I found a way to do this. In my case I am using xml as the datasource for the tree. I am binding the open_node event to the jstree in the following manner. Mind it that even though I am using xml, the internal structure is that of html data.
// jsTree Configuration hash
var jsTreeConfig = {};
$("#demo1").jstree( jsTreeConfig )
.bind('open_node.jstree', function( e, data ) {
var parentObj = data.rslt.obj; // parent object
var jstreeInstance = data.inst; // jstree instance
$(data.rslt.obj).find("li").each( function( idx, listItem ) {
var child = $(listItem); // child object
// do Stuff with child which can be any level of hierarchy depth
// ...
});
});
这篇关于jstree jquery插件 - 获取父节点的所有子节点和子子节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
The End



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)