Knockout.mapping.js - 更新 observableArray 不会更新 ko.compulated 值
根据knockout.mapping.js的文档,它说数据对象的属性成为可观察的,列表成为可观察的数组,但是我在更新应该是ko.mapping.fromJS的产品的可观察数组时遇到问题。
我创建了以下小提琴:
注意,当您单击“添加服务”按钮时,控制台显示 observableArray 已更新,但 formattedService 计算值不会更新。有什么想法我做错了吗?如果您更改文本区域,则名称是可编辑的,但是当您将某些内容推到服务列表上时,服务列表的计算值不会更新...
感谢您的任何想法!
based on the docs for knockout.mapping.js it says that properties of a data object become observables, and lists become observableArrays, however I'm having an issue updating an observableArray that should be the product of ko.mapping.fromJS.
I've created the following fiddle:
Notice, when you click the add service button, the console shows that the observableArray is updated, however the formattedService computed value does not update. Any ideas what I'm doing wrong? The name is editable if you change the text area, but the computed value for the services list does not update when you push something onto it...
Thanks for any ideas!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决了我的问题,我正在使用:
当我应该做的时候:
一旦我这样做了,一切都会正常。
Solved my problem, I was using:
when I should have been doing:
Everything works once I do that.