knockout.js - KnockoutJS - Updating ViewModel OnChange of textbox value instead of OnBlur Options -
i'm pretty new knockoutjs , love i've seen far. currently, when observable property of view model bound text property of text box (input type=text), viewmodel gets updated on blur event of textbox. there way update view model on change event of textbox? tried creating custom binding handler on wiring change event handler on text box in "init", somehow did not work. correct achieve goal? or there easier way?
you can use 'value' binding , add valueupdate
binding attribute specify when update control:
see here: http://knockoutjs.com/documentation/value-binding.html
<p>your value: <input data-bind="value: somevalue, valueupdate: 'afterkeydown'" /></p> <p>you have typed: <span data-bind="text: somevalue"></span></p> <!-- updates in real-time --> <script type="text/javascript"> var viewmodel = { somevalue: ko.observable("edit me") }; </script>
Comments
Post a Comment