jsTree-设置Json数据中的href属性

jsTree-设置Json数据中的href属性,json,href,jstree,Json,Href,Jstree,我试图创建一个“jsTree”树视图,从.NETWebService获取数据。 除a节点的href属性外,所有功能都正常工作。无论我尝试什么,它总是呈现为“#”。 从文档中我了解到,任何数据对象中的所有属性都会复制到a节点 下面是我当前json对象的一个示例。无论如何,您能否找出href属性未复制到节点的原因 [ { "attributes" : { "id" : "rootnode_2", "rel" : "root2" }, "children"

我试图创建一个“jsTree”树视图,从.NETWebService获取数据。 除a节点的href属性外,所有功能都正常工作。无论我尝试什么,它总是呈现为“#”。 从文档中我了解到,任何数据对象中的所有属性都会复制到a节点

下面是我当前json对象的一个示例。无论如何,您能否找出href属性未复制到节点的原因

    [ { "attributes" : { "id" : "rootnode_2",
        "rel" : "root2"
      },
    "children" : [ { "attributes" : { "id" : "childnode_9",
              "rel" : "folder"
            },
          "children" : [ { "attributes" : { "id" : "childnode_23",
                    "rel" : "folder"
                  },
                "children" : null,
                "data" : { "href" : "http://www.google.com",
                    "title" : "Test_Below_1"
                  },
                "state" : null
              } ],
          "data" : { "href" : "http://www.google.com",
              "title" : "Test_1"
            },
          "state" : null
        },
        { "attributes" : { "id" : "childnode_10",
              "rel" : "folder"
            },
          "children" : [ { "attributes" : { "id" : "childnode_24",
                    "rel" : "folder"
                  },
                "children" : null,
                "data" : { "href" : "http://www.google.com",
                    "title" : "Test_Below_2"
                  },
                "state" : null
              } ],
          "data" : { "href" : "http://www.google.com",
              "title" : "Test_2"
            },
          "state" : null
        }
      ],
    "data" : { "href" : "http://www.google.com",
        "title" : "Glatt"
      },
    "state" : "closed"
  } ]
这就是我初始化树的方式

$("#jstreejson").jstree({
        json_data : {
            "data": treeObject
        },
        themes: {
            "theme": "apple",
            "dots": true,
            "icons": true,
            "url": "/Scripts/themes/apple/style.css"
        },
        plugins: ['core', 'themes', 'json', "json_data"]
    });

所以。。。我不确定这是否完全正确。据我所知,您无法控制锚属性,但您可以在json中向
attr
散列添加内容,然后使用
select_node.jstree
事件打开所需链接,即:

.bind("select_node.jstree", function (e,data) {
   var href_address = data.rslt.obj.attr("whatever");
   // open desired link
}

尝试将href值添加到
attr
哈希,而不是
数据
哈希。