0

In knockout.js there are only 4 values for valueUpdate parameter for data binding: input, keyup, keypress and afterkeydown. But I want to update a property after key enter is pressed. Can I write custom valueUpdate event for this issue?

Something like this:

<input data-bind="value: value, valueUpdate: afterenterpress" />

Or can I achieve such behaviour another way?

Neshta
  • 2,605
  • 2
  • 27
  • 45

1 Answers1

0

Nope, you can't do this, not like you expect to be able to do it. You can check out the value binding source to see what happens to the value you pass to valueUpdate: an event handler is regestered for that event name which will update the corresponding observable.

There is no "afterenterpress" event, so you can't register something like that.

You will need to either use the event binding, or create custom binding akin to this solution.

Community
  • 1
  • 1
Jeroen
  • 60,696
  • 40
  • 206
  • 339