I am trying to get content from a JSON-object and dynamically built a ordered list with it (nested with sub(sub)items) with JavaScript. For the front-end lay-out I am using JS 'CollapsibleList' (http://code.stephenmorley.org/javascript/collapsible-lists/). In order to get the lay-out rendered right; I need to add the right class to the list item. This went well for some of them but I can't solve how to add the 'collapsibleListClosed' class.
I guess the sub-sub items also will give some problems with this approach.
The code I used is:
list = $("<ul class='treeView2' id='productTree'>");
for (var i = 0, l = jsonobject.length; i < l; ++i) {
list.append("<li><input type='text' value='" + jsonobject[i].id + "'</input><ul class='collapsibleList'><li class='collapsibleListClosed'>Test");
}
$("#goo").append(list);
})
});
The end-goal is that I for example have some Main items, subitems, sub- subitems and it automatically/dynamically generates the correct lists in the right structure
How can this be fixed please? Thank you!
inputdoesn't have a close tag in HTML, just:<input />or<input>>at the end of your input. your input tag should look like<input type='text' value='" + jsonobject[i].id + "'>it automatically/dynamically generates the correct lists in the right structurewhat structure? what have you tried?