KnockoutJS observableArray在内部观察值更改时更新 [英] KnockoutJS observableArray to update when inner observable is changed
问题描述
我需要知道在observableArray
内更改observable
时如何触发observableArray
的更新.
I need to know how to trigger the update for an observableArray
when an observable
is changed inside the observableArray
.
我有一个observableArray
代表一棵二叉树.我正在使用一个存储映射函数来获取和设置数组中的值,因此即使它可能只包含一个空的observable
,它也必须保持平衡.例如. nodes()[9]可能为空,但是当该节点更新时,我会调用nodes()[9](set new value)
并需要触发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
推荐答案
最终在observableArray上使用.replace()
Ended up using .replace() on the observableArray
这篇关于KnockoutJS observableArray在内部观察值更改时更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!