I'm having trouble understanding why this binding setup isn't working.
I have a Page object with an id and name, I have a pendingBatchDocument with a batchDocumentId observable and a pages observableArray. In my viewmodel, I'm trying to initialize an observable array with PendingBatchDocument's and initialize those PendingBatchDocuments with their array of Pages.
The syntax isn't giving me any errors so I assume the setup there is OK. Let me know if it isn't right.
My question is, why isn't the binding on the second foreach working?
View
<div data-bind="foreach: pendingDocs">
<ul class="sortable" data-bind="foreach: pendingDocs().pages()">
</ul>
</div>
Javascript View Model
function Page(id, name)
{
this.id = ko.observable(id);
this.name = ko.observable(name);
}
var PendingBatchDocument = function(batchDocumentId, pages)
{
this.batchDocumentId = ko.observable(batchDocumentId);
this.pages = ko.observableArray(pages);
};
var ViewModel = function()
{
this.list1 = ko.observableArray([
{ itemId: "C1", name: "Item C-1" },
{ itemId: "C2", name: "Item C-2"},
{ itemId: "C3", name: "Item C-3"},
{ itemId: "C4", name: "Item C-4"},
{ itemId: "C5", name: "Item C-5"},
{ itemId: "C6", name: "Item C-6"},
{ itemId: "C7", name: "Item C-7"}]);
this.pendingDocs = ko.observableArray([
new PendingBatchDocument(1, [
new Page(1, "Page 1"), new Page(2, "Page 2"), new Page(3, "Page 3")
])
]);
};
ko.applyBindings(new ViewModel());