简体   繁体   English

基因敲除ko.observableArray不会刷新视图

[英]knockout ko.observableArray doesn`t refresh the view

The code can be found here When I'm initializing observableArray and call ko.applyBindings it works well. 在初始化observableArray并调用ko.applyBindings时,可以在此处找到代码。 But any other changes to the view model are not displayed on ui. 但是对视图模型的任何其他更改都不会显示在ui上。 I'm adding another object to observableArray and knockout doesn't render it in the grid. 我正在向observableArray添加另一个对象,并且剔除不会将其呈现在网格中。

When you push to an observableArray, you want to call push directly on the observableArray itself and not just on the underlying array. 当您推送到observableArray时,您想直接在observableArray本身而不是仅在基础数组上调用push

So, you would want to call: 因此,您需要致电:

Categories.push instead of Categories().push . Categories.push而不是Categories().push

observableArrays include wrappers to many of the array functions that will perform the operation on the underlying array and notify any subscribers. observableArrays包含许多数组函数的包装器,这些函数将对基础数组执行操作并通知任何订阅者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM