I have a viewModel which has this observableArray
(function () {
function myItems() {
var self = this;
self.itemArray = ko.observableArray();
somefunction() {...
}
var myViewModel = new myItems();
This observableArray will contain instances of this:
(function () {
function item() {
var self = this;
self.name = ko.observable("some data");
self.doStuff = function () {
return "doing whatever";
};
}
window.item = item
}());
I map my json into the viewModel
var json = '{"name":"my main property", "itemArray": [ { "name": "Bob" }, { "name" : "Fred" } ] }';
var myViewModel = new myItems();
ko.mapping.fromJSON(state, {}, myViewModel);
How do I tell the mapping that it must map itemArray using the item object? How do I create the link between item() and myItems()?
Here's a fiddle showing the issue http://jsfiddle.net/dexster/hLEMz/7/