插件用的是bootstra-treeview,根据客户要求需要点击节点名称也可以展开树状图。求各位大神指导!
js代码如下:
bar data = JSON l.parse(theString)
$(‘#tree’).treeview({data :data,multiSelect:false,
enableLinks:true,highlightSelected:false,
showIcon:false,emptyIcon:””,
showBorder:true,
onNodeSelected:function(event,data){},
}).treeview(‘collapseAll’,{silent:true});theString的格式如下:
"[{\"icon\":null,
\"text\":\"Report\",
\"tags\":null,
\"href\":null,
\"nodes\":[{\"icon\":null,\"text\":\"Head Count Report\",\"tags\":null,\"href\":\"/Report/HeadCount\",\"nodes\":null},
{\"icon\":null,\"text\":\"Head Count Report (KL)\",\"tags\":null,\"href\":\"/Report/HeadCountByJobGrade\",\"nodes\":null}]}]"
js代码如下:
bar data = JSON l.parse(theString)
$(‘#tree’).treeview({data :data,multiSelect:false,
enableLinks:true,highlightSelected:false,
showIcon:false,emptyIcon:””,
showBorder:true,
onNodeSelected:function(event,data){},
}).treeview(‘collapseAll’,{silent:true});theString的格式如下:
"[{\"icon\":null,
\"text\":\"Report\",
\"tags\":null,
\"href\":null,
\"nodes\":[{\"icon\":null,\"text\":\"Head Count Report\",\"tags\":null,\"href\":\"/Report/HeadCount\",\"nodes\":null},
{\"icon\":null,\"text\":\"Head Count Report (KL)\",\"tags\":null,\"href\":\"/Report/HeadCountByJobGrade\",\"nodes\":null}]}]"
$(function(){
$('a[href^="#"]').on("click",function(){
$(this).parent().find(".glyphicon")[0].click();
});
});
$(function(){
$('.node-treeview2').on("click",function(){
$(this).find(".glyphicon")[0].click();
});
});
放在 body 里最下面用<script>括起来。用下面的代码$(function(){
$('.node-treeview2').on("click",function(){
$(this).find(".glyphicon")[0].click();
});
});
$(function(){
$('a[href^="#"]').on("click",function(){
$(this).parent().find(".glyphicon")[0].click();
});
});不是用$(function(){
$('.node-treeview2').on("click",function(){
$(this).find(".glyphicon")[0].click();
});
});