I\'m trying to create a nested UL from JSON. I am able to loop through and grab the data from the object, but I am having trouble building the nested UL. I figure the \'.app
Most of what you make is dynamic so start with something like this
Then in your code use the things you just made and add to them. Something like this:
for(var i = 0; i < menu.length; i++){
var navItem = menu[i];
subMenuL1 = mainMenu.append('- ' + navItem.title +'
');
for(var j = 0; j < menu[i].menu.length; j++){
var navItemLevel1 = navItem.menu[j];
subMenuL2 = subMenuL1.append('- ' + navItemLevel1.title +'
');
for(var k = 0; k < menu[i].menu[j].menu.length; k++){
var navItemLevel2 = navItemLevel1.menu[k];
subMenuL2.append('- ' + navItemLevel2.title +'
');
}
}
};
Note: I did not test at all... just looked at the example code and made a few changes to get you in the right direction.