Simple binding handlers
Binding handlers can range from very simple to whole applications by themselves. As the purpose of binding handlers is to translate between the presentation layer (HTML) and the viewmodel (JavaScript), the binding handler's complexity is directly related to the complexity of the UI interaction and the bound data. Simple tasks such as hiding or showing an element with animation will have very thin handlers, while data binding on an interactive map element will require much more logic.
Animated binding handlers
As DOM interaction in the primary use case for jQuery, and given its popularity, it is not uncommon to use jQuery inside Knockout binding handlers. The canonical custom binding handler example from the Knockout documentation is a binding to hide and show elements, with the jQuery's slideUp
and slideDown
methods, instead of using the standard visible
binding to switch them on and off:
ko.bindingHandlers.slideVisible = { init: function(element, valueAccessor...