0
我想动态加载我的JSON响应中的复选框项目,因为我写了下面的代码,但它不工作。highchecktree动态加载json数组
代码:
var mockData = { children: []};
if (parsedJSONObject.menuFunctions instanceof Array) {
$.each(parsedJSONObject.menuFunctions, function(i, obj) {
mockData.push({
item:{
id: obj.menuId,
menuDisplayName: obj.menuDisplayName,
checked: false
});
if (obj.hasOwnProperty("childMenus")) {
var childMenu = "";
if (obj.childMenus instanceof Array) {
$.each(obj.childMenus, function(j, childObj) {
mockData.children.push({
item:{
id:childObj.menuId,
menuDisplayName:childObj.menuDisplayName,
checked: false
});
});
}
}
});
}
}
我的JSON响应:
{"loginStatus":"Y","menuFunctions":[{"menuDisplayName":"My Document","menuId":"10127"},{"menuDisplayName":"Health
Topic","menuId":"10128","parentMenuId":"-1"},{"menuDisplayName":"Alerts","menuId":"10129","parentMenuId":"-1"},{"childMenus":[{"menuDisplayName":"Conditions","menuId":"10131","parentMenuI
d":"10130"},{"menuDisplayName":"Procedures and
Surgeries","menuId":"10132","parentMenuId":"10130"}]}
我尝试了上面的代码,但没有发生,我不知道我做错了。请帮忙。
_“我尝试了上面的代码,但没有发生我不'我不知道我做错了什么'_我很抱歉,但这不是问题。 ---“没有任何事情发生”是什么意思? ---你想达到什么目的? - - 更加详细一些。 – evolutionxbox
@evolutionxbox抱歉不准确。我无法将**子**推入同一阵列,这是我的问题。我正在关注此链接http://www.jqueryscript.net/other/jQuery-Plugin-To-Create-Checkbox-Tree-View-highchecktree.html – Ironman
对不起。我的评论很匆忙。原谅基调。 – evolutionxbox