knockout valueUpdate example
by Dejan Vasic
HTML
<div>Word Count : <span data-bind="text: count"></span>
</div>
<div>
<textarea data-bind="value: comment, html: comment, valueUpdate: ['afterkeydown', 'input'] " rows="5" />
</div>
JavaScript
var simpleModel = function () {
var self = this;
self.comment = ko.observable("this<is> the officia's crap");
self.count = ko.computed(function(){
var count = self.comment().split(' ').length;
return count;
});
}
var modelObject = new simpleModel();
ko.applyBindings(modelObject);