插件用的是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}]}]"
     

解决方案 »

  1.   

    给你个暴力的方法:
    $(function(){
      $('a[href^="#"]').on("click",function(){
        $(this).parent().find(".glyphicon")[0].click();
      });
    });
      

  2.   

    加在onNodeSelected内么?还是?
      

  3.   

    给你个暴力的方法:
    $(function(){
      $('.node-treeview2').on("click",function(){
        $(this).find(".glyphicon")[0].click();
      });
    });
      

  4.   


    放在 body 里最下面用<script>括起来。用下面的代码$(function(){
      $('.node-treeview2').on("click",function(){
        $(this).find(".glyphicon")[0].click();
      });
    });
      

  5.   

    如果,你的文字内容是一个<a>括起来的,用
    $(function(){
      $('a[href^="#"]').on("click",function(){
        $(this).parent().find(".glyphicon")[0].click();
      });
    });不是用$(function(){
      $('.node-treeview2').on("click",function(){
        $(this).find(".glyphicon")[0].click();
      });
    });
      

  6.   

    F12调试没有。看看是不是有错误。https://www.npmjs.com/package/bootstrap-treeview 里有API文档。getCollapsed() expandNode(node | nodeId, options)collapseNode(node | nodeId, options)