Book Image

Mastering KnockoutJS

By : Timothy Moran
Book Image

Mastering KnockoutJS

By: Timothy Moran

Overview of this book

Table of Contents (16 chapters)
Mastering KnockoutJS
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Binding providers


With a binding preprocessor, we have access to the binding expression and can modify it before the evaluation of bindings. With a node preprocessor, we have access to the node and can modify the DOM before bindings are applied. Both of these just transform things into the normal Knockout syntax. They are also limited to operating on the DOM, and they do not have access to the binding context.

Knockout binding providers are objects that receive both the DOM node and the binding context and determine which bindings handlers will be applied and what valueAccessor properties those bindings receive.

A binding provider is expected to provide the following functions:

  • nodeHasBindings(node): This function should return a Boolean that indicates whether or not the node has any bindings defined on it.

  • getBindingAccessors(node, bindingContext): This function should return an object with a property for each binding to be applied whose value is a function that evaluates the binding expression...