我已经使用jquery设计了TreeView,并且它与ajax响应(动态地)绑定。
现在,我希望每个li元素的OnClick()都显示folder1 > Folder 1-1 > Folder 1-1-1
之类的路径,依此类推
我的DOM代码是:
function loadSubFolders(folderId) {
$.ajax({
dataType : "json",
url : "loadChildFolders",
type : 'GET',
data : {id : folderId},
success : function(response) {
if (response.length != null) {
for (i = 0; i < response.length; i++) {
$(".treeOne").append("<li id="+response[i].folderId+" value="+response[i].folderNm+"><a>"+ response[i].folderNm
+ "</a><ul class="+response[i].folderId+"></ul></li>");
var subList = response[i].listOfFolder;
getChildSubFolder(subList,response[i].folderId);
}
}
$('#tree1').treed();
},
error : function(res, textStatus) {
var msg = "Unable to load Subfolder";
alert(msg);
}
});
}
function getChildSubFolder(subList, parentId) {
if (subList.length > 0) {
var count = subList.length;
for (j = 0; j < count; j++) {
var temp = j;
if (parentId == subList[j].rootId) {
$("." + parentId).append("<li id="+subList[j].folderId+" value="+subList[j].folderNm+"><a>"+ subList[j].folderNm
+ "</a><ul class="+subList[j].folderId+"></ul></li></ul>");
var subChildList = subList[j].listOfFolder;
if (subChildList.length > 0) {
getChildSubFolder(subChildList,
subList[j].folderId);
}
j = temp;
}
}
}
}
我该怎么办?
请帮助我!