当淘汰赛更新值时,更改事件不会触发 [英] Change event doesn't trigger when Knockout updates value

查看:51
本文介绍了当淘汰赛更新值时,更改事件不会触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个外部javascript库,可在更改textarea时触发该触发器,对其进行格式化等.

I have an external javascript library which triggers on the change of a textarea, formats it, etc.

但是,当KnockoutJS将值设置为textarea时,不会触发change事件. 我的问题的简化提琴.当敲除更新我的textarea的值时,是否可以触发更改事件?

However, when KnockoutJS sets the value to the textarea, the change event isn't fired. Simplified Fiddle of my problem. Is it possible to fire the change event when Knockout updates the value of my textarea?

推荐答案

您可以在基础可观察对象上设置订阅,而不是尝试强制Knockout处理更改事件.像这样: http://jsfiddle.net/EZC9E/1/

Rather than trying to force Knockout to work with change events you can setup a subscription on the underlying observable. Like this: http://jsfiddle.net/EZC9E/1/

this.text.subscribe(function(newValue) {
    alert('Text is changing to ' + newValue);
});        

这篇关于当淘汰赛更新值时,更改事件不会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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