Determining the State of a ToggleSwitch

You can detect whether a ToggleSwitch control is in a checked or unchecked state by reading the ToggleSwitch control’s checked property. For example, the page in Listing 4.5 contains a ToggleSwitch control and a DIV element that displays different messages depending on the state of the ToggleSwitch control (see Figure 4.9).

Image

FIGURE 4.9 Displaying a message depending on the state of a ToggleSwitch

LISTING 4.5 Using a ToggleSwitch Control (toggleSwitchChecked\toggleSwitchChecked.html)

<div id="togFlux"    data-win-control="WinJS.UI.ToggleSwitch"    data-win-options="{         ...

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.