Change event doesn't trigger when Knockout updates value

后端 未结 2 1911
闹比i
闹比i 2021-02-19 13:09

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

However, when KnockoutJS sets the value to the textarea, the change ev

2条回答
  •  花落未央
    2021-02-19 14:12

    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);
    });        
    

提交回复
热议问题