KnockoutJS bind to div as I'm typing in textarea
asp.net, javascript, knockout.js
Solution
The `value` binding has a companion option called `valueUpdate` that you can set to include additional events like:
data-bind="value: CommentTextPlain, valueUpdate: 'afterkeydown'"
Problem
Is it possible in Knockout to have a "live" binding between a text area and a DIV on the page that updates the DIV every time the content of the textarea changes (character per character)? I am using a computed field on my view model, but it won't update the DIV unless I tab off the textarea: Is it possible to update it instantly every time a change is made, without having to tab off? Code ``` function EditModel() { this.CommentTextPlain = ko.observable(""); var self = this; this.CommentReady = ko.computed(function () { return self.CommentTextPlain().replace(regex, "<BR>"); }); } function ApplyViewmodel() { model = new EditModel(); ko.applyBindings(model, document.getElementById("mainContainer")); } <div id="mainContainer"> <div id="target" data-bind='html: CommentReady' class="commentEditBox"></div> <textarea data-bind="value: CommentTextPlain" rows="20" cols="62" id="editBoxFull"> </textarea> </div> ```