Chapter 9. The Mapping Plugin
This can be extremely useful in several different situations. Where we had been creating objects and manually defining each property as observable, the mapping plugin will do this automatically.
Map from an Object
In Example 9-1, I convert an example from Chapter 3 that demonstrates the
with binding on a single
book object. In the original example, a
book object is passed to the
ViewModel via the constructor. This is then directly assigned to the internal
book property and used for displaying with Knockout bindings. However, because it is using the mapping plugin, all of the properties (
publishedDate) are now being observed.
Example 9-1. Mapping from an object
<title>Data Binding with KnockoutJS