Retrieving Controls from an HTML Document

When a control gets created, it is always associated with a DOM element. The DOM element is the “host” for the control.

You can retrieve a control from its associated DOM element by using the winControl property. Every DOM element that has an associated control has a winControl property that represents the control.

For example, if you declare a DatePicker control like this:

<div id="dateBirthday"    data-win-control="WinJS.UI.DatePicker"></div>

Then you can retrieve the DatePicker control in your JavaScript code like this:

(function () {    "use strict";    function initialize() {        WinJS.UI.processAll().done(function () {            var ...

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.