大佬教程收集整理的这篇文章主要介绍了jquery – JSTREE – 刷新jstree,以便重新运行’bind(“loaded.jstree”)’中的所有代码,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<input type="button" value="Test" onclick='$j("#demo2").jstree("refresh");'/>
现在,当jstree加载时,从2D阵列读取数据,并根据在该阵列中找到的数据更改节点图标.
我需要一个功能,它将刷新或重新加载jstree,同时根据从2D数组读取的数据显示节点的正确图标.
如果我使用’$j(“#demo2”).jstree(“refresh”);’,则重新加载树,但它不会保留其先前的打开状态.
jstree代码
$j("#demo2").jstree({ "ui" : { "SELEct_limit" : -1,"SELEct_multiple_modifier" : "ctrl","SELEct_range_modifier" :"shift",},"json_data" : { "progressive_render" : false,"SELEcted_parent_open": true,"ajax" : { "url" : "/json/test1.json" } },"plugins" : [ "themes","json_data","ui","crrm","contextmenu" ],'contextmenu' : { 'items' : customMenu } })//end of jstree function /*************************************************************************** When the jstree is first loaded,loop through the data retrieved from the database (stored prevIoUsly in a 2d array called 'status_from_db') and SELEct all jstree nodes found in that array. ***************************************************************************/ $j("#demo2").bind("loaded.jstree",function (e,data) { var inst = data.inst; var i; for (i = 0; i < status_from_db.length; ++i) { var node_name = status_from_db[i][0]; $j("#demo2").find($j("lI[name='"+node_name+"']")).each(function (k,v) { inst.SELEct_node(v); /*************************************************************************** Based on the retrieved data,assign the correct class to the variable 'SELEcted_class and then modify the class of the <li> tag of the respective node. ***************************************************************************/ var node_strength = status_from_db[i][1]; var node_add_strength = status_from_db[i][2]; var SELEcted_class; if (node_strength == "present" && node_add_strength == ""){ SELEcted_class = "jstree-icon4"; } else if (node_strength == "present" && node_add_strength == "strong") { SELEcted_class = "jstree-icon3"; } $j("lI[name='"+node_name+"'] > ins").attr("class",SELEcted_class);// set class to display new icon $j("lI[name='"+node_name+"'] > a ins").attr("class",SELEcted_class);// set class to display new icon }); } }); });
有没有办法重新加载/刷新树,以便’$j(“#demo2”).bind(“loaded.jstree”,函数(e,data){‘函数)中的所有代码重新运行?
以上是大佬教程为你收集整理的jquery – JSTREE – 刷新jstree,以便重新运行’bind(“loaded.jstree”)’中的所有代码全部内容,希望文章能够帮你解决jquery – JSTREE – 刷新jstree,以便重新运行’bind(“loaded.jstree”)’中的所有代码所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。