2013-02-15 74 views
0

我正在使用dynatree並添加了一個自定義hoverover菜單,其中包含指向頁面的鏈接;不過,我想不通爲什麼我的鏈接到其他網頁都沒有開火..如何在自定義節點上的dynatree中創建鏈接?

這裏是我的樹代碼:

<script type="text/javascript"> 
     $(function() { 
      $("#catTree2").dynatree({ 
       checkbox: false, 
       selectMode: 3, 
       children: [ 
        {title: "First Year", isFolder: true, 
          children: [ 
         {title: "ESUNRS 110 (Intro to Nursing I)"}, 
         {title: "ESUNRS 112 (Intro to Nursing II)"}, 
         {title: "ESUNRS 120 (Pharmacology in Nursing)"} ]},  
        {title: "Second Year", isFolder: true, 
          children: [ 
         {title: "ESUNRS 200 (Seminar I)"}, 
         {title: "ESUNRS 201 (Seminar II)"}, 
         {title: "ESUNRS 220 (Nursing of Adults I)"}, 
         {title: "ESUNRS 221 (Nursing of Adults II)"}, 
         {title: "ESUNRS 224 (Child and Mental Health Nursing I)"}, 
         {title: "ESUNRS 225 (Child and Mental Health Nursing II)"} ]}, 
        {title: "Third Year", isFolder: true, 
          children: [ 
         {title: "ESUNRS 300 (Seminar III)"}, 
         {title: "ESUNRS 320 (Maternal-Newborn Nursing)"}, 
         {title: "ESUNRS 322 (Management in Nursing)", isFolder: true, 
          children: [ 
          {title: "Example Questions"} ]}, ]},   
        ], 
       onCustomRender: function (node) { 
        var html = "<span class='dynatree-title' href='#'>"; 
         html += "<span class='td'>"; 
         html += node.data.title; 
         html += "</span>"; 
         html += "<span class='td'>"; 
         html += "<ul id='options'>"; 
         html += "<li class='image'>"; 
         html += "<img src='/Icons/cog.png' alt='Options Menu'/>"; 
         html += "<ul class='optionsMenu' style='top:20px;right:-119px;'>"; 
         html += "<li>"; 
         html += "<a href='#' class='createFolderOpen'>"; 
         html += "New Folder"; 
         html += "</a>"; 
         html += "</li>"; 
         html += "<li>"; 
         html += "<a href='#' class='editFolderOpen'>"; 
         html += "Edit Folder"; 
         html += "</a>"; 
         html += "</li>"; 
         html += "<li>"; 
         html += "<a href='#' class='deleteFolderOpen'>"; 
         html += "Delete Folder"; 
         html += "</a>"; 
         html += "</li>"; 
         html += "<li>"; 
         html += "<a href='#' class='shareFolderOpen'>"; 
         html += "Share Folder"; 
         html += "</a>"; 
         html += "</li>"; 
         html += "<li>"; 
         html += "Create New Question"; 
         html += "<ul style='top:136px;right:-120px;'>"; 
         html += "<li>"; 
         html += "<a href='http://74.39.250.15/questions_create.asp'>"; 
         html += "Multiple Choice"; 
         html += "</a>"; 
         html += "</li>"; 
         html += "<li>"; 
         html += "<a href='questions_create_tf.asp'>"; 
         html += "True/False"; 
         html += "</a>"; 
         html += "</li>"; 
         html += "<li>"; 
         html += "<a href='questions_create_essay.asp'>"; 
         html += "Essay"; 
         html += "</a>"; 
         html += "</li>"; 
         html += "<li>"; 
         html += "<a href='questions_create_fitb.asp'>"; 
         html += "Fill in the Blank"; 
         html += "</a>"; 
         html += "</li>"; 
         html += "</ul>"; 
         html += "</li>"; 
         html += "<li>"; 
         html += "<a href='questions_import.asp'>"; 
         html += "Import Questions"; 
         html += "</a>"; 
         html += "</li>"; 
         html += "<li>"; 
         html += "<a href='#' class='exportQuestionsOpen'>"; 
         html += "Export Questions"; 
         html += "</a>"; 
         html += "</li>"; 
         html += "</ul>"; 
         html += "</li>"; 
         html += "</ul>"; 
         html += "</span>"; 
         html += "<span class='td'>"; 
         html += "55"; 
         html += "</span>"; 
         html += "</span>"; 
         return html; 
       }, 
       //children: treeData, 
       onSelect: function(select, node) { 
        // Get a list of all selected nodes, and convert to a key array: 
        var selKeys = $.map(node.tree.getSelectedNodes(), function(node) { 
         return node.data.key; 
        }); 
        $("#echoSelection4").text(selKeys.join(", ")); 

        // Get a list of all selected TOP nodes 
        var selRootNodes = node.tree.getSelectedNodes(true); 
        // ... and convert to a key array: 
        var selRootKeys = $.map(selRootNodes, function(node) { 
         return node.data.key; 
        }); 
        $("#echoSelectionRootKeys4").text(selRootKeys.join(", ")); 
        $("#echoSelectionRoots4").text(selRootNodes.join(", ")); 
       }, 
       onDblClick: function(node, event) { 
        node.toggleSelect(); 
       }, 
       onKeydown: function(node, event) { 
        if (event.which == 32) { 
         node.toggleSelect(); 
         return false; 
        } 
       } 
      }); 
     }); 
</script> 

爲什麼我的鏈接無法正常工作?

回答

1

有點老,但我用:

onCustomRender: function(node) { 
var html = "<a href='xxxxx?FileId=" + node.data.key + "'>";        
html += xxxxxxxxxxxx+"</a>"; 
return html; 
} 
+0

一個很老的問題,我終於想通了 - 不過這是爲了做這件事。 – boy 2013-11-21 15:19:31

相關問題