O'Reilly logo

Mastering KnockoutJS by Timothy Moran

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Node preprocessors

Binding handler preprocessors are attached to individual binding handlers and work by modifying the binding string. They only apply to nodes of their respective handler.

Node preprocessors, on the other hand, are called on every DOM node. They run when the UI is first bound and when it is modified by bindings such as foreach or template.

The purpose of a node preprocessor is to modify the DOM before data-binding occurs, as opposed to a binding preprocessor that only modifies the data-bind attribute. A node preprocessor is defined by adding a preprocessNode function to the binding provider:

ko.bindingProvider.instance.preprocessNode = function(node) {
  /* DOM code */
}

A preprocessor is called once for each node. If no changes need ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required