2
我試圖創建一個'jsTree'樹視圖,它從.Net webservice獲取數據。 除a節點的href屬性外,一切正常。無論我嘗試什麼,它總是呈現爲'#'。 據我所知,任何數據對象中的所有屬性都被複制到a節點。jsTree - 在Json數據中設置href屬性
下面是我當前的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"]
});
嘗試將href值添加到'attr'哈希值,而不是'data'哈希值。 – Amir 2012-03-01 13:57:01
完美運作。謝謝! – Erik 2012-03-01 14:02:04