function formCategoryTrees(object) {
_.each(object,function(objectValues){
var leafCategoryId = objectValues["id"];
var leafCategoryName = objectValues["name"];
console.log(leafCategoryName+""+leafCategoryId );
if (objectValues.hasOwnProperty("children")) {
if (typeof objectValues["children"] == 'object')
console.log("In");
formCategoryTrees(objectValues["children"]);
}else{
console.log(leafCategoryName);
}
})
}
So i want to display the category tree as follows: Mobile & Accessories -> Mobiles
Mobile & Accessories -> Chargers
My JS Fiddle: http://jsfiddle.net/tfa8n5tj/
See http://jsfiddle.net/sjmcpherso/kc9fehyz/ here I've created a hierarchical set of list elements using recursion & iteration. As manipulation of the DOM in loops can greatly affect performance, I have created a virtual DOM and append to the real DOM at the end of the process.
I believe you want your function to look like the following: