[英]Knockout Observable Array Not Updating
使用Knockout.JS 3.0,我试图创建一个可观察的数组,然后在我的SelectedCustomer.subscribe函数中更新该数组。 我的变量notes可以很好地加载,这是它在控制台日志中返回的内容:[Array [7]],但是当我记录我的observableArray notesTable时,它仅记录[]。 基本上,我有一个foreach绑定,它基于数组创建一个表,并且不加载任何数据。
self.notesTable = ko.observableArray();
self.SelectedCustomer.subscribe(function () {
var x = document.getElementById('customerselect').value;
if (x != "Select A Customer") {
var notes = GetNotes(x);
console.log("notes =");
console.log(notes);
self.notesTable(notes);
console.log(self.notesTable);
}
});
如评论所建议-您需要将其称为console.log(self.notesTable())
;
对于文档ko.obervableArray
没有明确说明这一点- http://knockoutjs.com/documentation/observableArrays.html
它是从隐含ko.observable
这里列出文档- http://knockoutjs.com/documentation/observables.html#reading_and_writing_observables
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.