So, I'm learning knockout.js , and I'm a bit puzzled by how to create nested complex types in it.
For example, on my server side, my model is:
class Person { public string Name {get; set;} public int Age {get; set;} public List<Colors> FavoriteColors {get; set;} } class Color { public int ColorId {get; set;} public string Name {get; set;} }
JSON that asp.net mvc produces something like (if I deduce the List<Person> ):
[{"Name":"JC","Age":24,"Colors":[{"ColorId":1,"Name":"Red"},{"ColorId":2,"Name":"Blue"}]}, {"Name":"Albert","Age":29,"Colors":{"ColorId":2,"Name":"Blue"}}]
Now I want to map this through observables, obtained through jquery ajax. I know that FavoriteColors will be an array, but I'm a little confused about how the training will be here ...
Any help would be greatly appreciated!
UPDATE:
Can anyone help me with this? (I made a prototype, but my choice does not work)
http://jsbin.com/eqihun/3/edit#javascript,html,live