如何在自定义节点上的dynatree中创建链接?

时间:2013-02-15 16:49:35

标签: dynatree

我正在使用dynatree并添加了一个带有页面链接的自定义hoverover菜单;但是,我无法弄清楚为什么我与其他页面的链接没有被解雇..

这是我的树代码:

<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 个答案:

答案 0 :(得分:1)

有点老但我用的是:

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