KnockoutJS observableArray在内部观察值更改时更新 [英] KnockoutJS observableArray to update when inner observable is changed

查看:67
本文介绍了KnockoutJS observableArray在内部观察值更改时更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆