如何在FancyTree中拥有链接


How to have a link in a FancyTree

我尝试使用一个fancytree。所有内容都显示正确,但我无法在节点的文本上有链接。。。为什么?如何解决这个问题?

我试着把html链接这样:

 <div id="tree">    
    <ul>
        <li><a href="..."> My Link to view 1 </a></li>
        <li><a href="..."> My Link to view 2 </a>
            <ul>
                 <li><a href="..." > My link to view 2, 1st object </a></li>
                 <li><a href="..." > My link to view 2, 2nd object </a></li>
                 ...
            </ul>
        </li>
        ...
    <ul>
 </div>

或者我试过

<li Onclick="clickEntite('''.Yii::app()->CreateAbsoluteUrl($axe['id_entite'].'/view',array('id'=>$axe['id_entite'])).''')" >'.$axe['text'].'</li>

  <script type="text/javascript">
function clickEntite(url){
    window.location.href=url;       
};
  </script>

没有取得任何成功。

看来FancyTree删除了他节点上的所有链接。

当节点处于活动状态或选中复选框时,是否可以重定向到右侧视图?

提前谢谢。

要在节点上有链接,插件中有几个选项。

当它被聚焦、激活或点击时重定向。

这是我为不同选项找到的代码。(我用激活的)

        focus: function(event, data) {
            var node = data.node;
            // Auto-activate focused node after 1 second
            if(node.data.href){
                node.scheduleAction("activate", 1000);
            }
        },
        activate: function(event, data){
            var node = data.node,
                orgEvent = data.originalEvent;
            if(node.data.href){
                //window.open(node.data.href, (orgEvent.ctrlKey || orgEvent.metaKey) ? "_blank" /*node.data.target*/ : node.data.target);
                window.location.href=node.data.href;    
            }
        },
        click: function(event, data){ // allow re-loads
            var node = data.node,
                orgEvent = data.originalEvent;
            if(node.isActive() && node.data.href){
                // data.tree.reactivate();
                window.open(node.data.href, (orgEvent.ctrlKey || orgEvent.metaKey) ? "_blank" : node.data.target);
            }
        }