Hi,
I have to retrieve a list of menu item from a database and display it in a tree structure.I want to use the menu name as the node name and menu id as the id of the node.I’m using php and jstree javascript library
This is what i wrote but it doesn’t give any output.this is what i hv done so far
function createNodeList(){
$('#menuCPanel #contentData #tree').jstree({
"json_data" : {
"ajax" :{
"type" : "POST",
"url" : "?m=admin",
"dataType" : "json",
"data" : {
"action" : "getNodeList",
},
"success" : function(result){
return {
id : result.attr ? result.attr("id") : result['menuId'],
title : result.attr ? result.attr("title") : result['menuName']
};
},
"error" : function(XMLHttpRequest, textStatus, errorThrown) {
alert("err: "+errorThrown);
},
},
},
"callback" : {
},
"themes" : {
"theme" : "classic",
"dots" : true,
"icons" : true
},
"plugins" : ["json_data", "themes"]
}).bind("select_node.jstree", function (e, data) { alert(jQuery.data(data.rslt.obj[0], "jstree").id) });
}
I would like to know what is wrong with the code.In fact the code returns the desired json data.this is the returned json data
“data”:[{“menuId”:“1”,“menuName”:“Top Menu”},{“menuId”:“2”,“menuName”:“Main Menu”},{“menuId”:“3”,“menuName”:“Bottom Menu”},{“menuId”:“4”,“menuName”:“Main Menu”}]
It would be a greate help if someone can help me
thanks in advance