KnockoutJS observableArray to update when inner observable is changed

最后都变了- 提交于 2019-12-13 13:09:23

问题


I need to know how to trigger the update for an observableArray when an observable is changed inside the observableArray.

I have an observableArray that represents a binary tree. I'm using a storage mapping function to get and set the values in the array so it has to be balance even thought it might only contain an empty observable. E.g. nodes()[9] maybe null but when that node is updated I would call nodes()[9](set new value) and need to trigger the observableArray to update


回答1:


Ended up using .replace() on the observableArray




回答2:


Managed to look through the code and find observableArray.replace ()

RELATED: How to replace a given index element in knockoutjs



来源:https://stackoverflow.com/questions/8774943/knockoutjs-observablearray-to-update-when-inner-observable-is-changed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!