How to make your custom binding handler two-way binding — Knockoutjs

Sami C.
1 min readMar 19, 2020

--

For my few people who are still writing Knockoutjs. A quick way to make your custom binding two way binding:

In the init function add:

ko.bindingHandlers.value.init(element, valueAccessor, allBindingsAccessor);

In the update function add:

ko.bindingHandlers.value.update(element, valueAccessor);

That’s all! Now you have two-way binding in your custom binding handler.

Enjoy

--

--

Sami C.
Sami C.

Written by Sami C.

Freelance Software Engineer

No responses yet