Declarative Data Binding and Observables

Declarative data binding and observables are a powerful combination. If you use observables with data binding then you can update the contents of an HTML document automatically whenever you change the underlying JavaScript objects.

For example, the HTML page in Listing 3.7 contains a SPAN and a BUTTON element. The page displays the number of times the button has been clicked (see Figure 3.6).

Image

FIGURE 3.6 Displaying a click count

LISTING 3.7 Using Data Binding with an Observable (dataBindingObservables\dataBindingObservables.html)

<!DOCTYPE html><html><head>    <meta charset ...

Get Windows® 8.1 Apps with HTML5 and JavaScript Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.