I have a tree of objects in my viewModel. The objects are something like this:
function Node() {
var self = this;
self.otherNodes = ko.observableArray([]);
self.moreNodes = ko.observableArray([]);
}
So, the viewModel has a root node filled with Node objects in the root objects two arrays. Those Nodes may in turn have more Nodes in their arrays arbitrarily deep.
I’m having difficulty displaying this data structure in my view. A tree always suggests recursion to me but I’m not sure how to do that using knockoutjs. Any suggestions?
Template bindings can refer to themselves:
http://jsfiddle.net/rniemeyer/UmBku/2/
some more tips here:
https://groups.google.com/forum/?fromgroups#!topic/knockoutjs/-x4X2AJK0HY