Capturing the Contents of an HTML Form

The WinJS library does not support two-way data binding. Change notification is one-way. If you want to capture the contents of an HTML form then you need to do the work of retrieving the values of the form elements yourself.

The page in Listing 3.9 contains an HTML form for creating a new product. It has two INPUT elements for the product name and price (see Figure 3.7). The form uses a single data-win-bind attribute. The FORM element has a data-win-bind attribute that wires up a form submit handler.

Image

FIGURE 3.7 Creating a new product

LISTING 3.9 Two-Way Data Binding (dataBindingTwoWay\dataBindingTwoWay.html) ...

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.