How to set valueUpdate binding globally in knockoutjs?

I just started using knockoutjs, and I could not find a way to bind valueUpdate to afterkeydown for all input fields at once. Is there a way to do this or do I really need to add valueUpdate: afterKeyDown for each input field?

Thank you in advance

+4
source share
1 answer

You can use this binding provider plugin

https://github.com/rniemeyer/knockout-classBindingProvider

Or you can create a custom snap

http://jsfiddle.net/4jRKV/

ko.bindingHandlers.value2 = { init: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { ko.applyBindingsToNode(element, { value: valueAccessor(), valueUpdate: "afterkeydown" }); } }; 
+3
source

Source: https://habr.com/ru/post/1479954/


All Articles