Kendo UI: Force update of ViewModel on KeyPress in TextBox
binding, kendo-ui, mvvm
Solution
Use the data-value-update attribute. Using the "keypress" event does not update the last character to the bound model, so use the "keyup" event instead.
<input id="name" type="text"
data-bind="value: name" data-value-update="keyup">
I initially tested using "keypress", but entering text "abcd" results in "abc" in the ViewModel.
Problem
I have a textbox field that has its value property bound to a property in my ViewModel. The problem is that the ViewModel is by default updated on the "changed" event of the textbox (when the textbox loses its focus). I want the ViewModel to be updated when the keypress event is executed. I don't want to force the "changed" event in every keypress, as there is some logic in that event handler and it doesn't have to be executed for every keystroke. Is there a way to tell Kendo to update the ViewModel without triggering the "changed" event? I know I can just manually modify the ViewModel, but I wanted something simpler and automated. Thanks for your answers, - Will