Declarative Data Binding and WinJS Controls

We discuss WinJS controls in detail in the next chapter; however, I want to make sure that you understand that you can use declarative data binding with WinJS controls properties in the same way as you can use declarative data binding with element attributes.

The trick is to use the winControl property, which is exposed by every HTML element that is associated with a control. You can use the winControl property with the data-win-bind attribute.

For example, the page in Listing 3.11 contains a WinJS Rating control (see Figure 3.8).

Image

FIGURE 3.8 Displaying an average rating with declarative data binding ...

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.