Switch

A switch widget.

Included in: dx.phonejs.js, dx.all.js

The dxSwitch widget is a switch that can have an on or off state.

This widget, like any other DevExtreme UI widget, can be created using one of three possible approaches: jQuery, Knockout or AngularJS. The following code demonstrates how to create the dxSwitch widget using the Knockout approach.

HTML
<div data-bind="dxSwitch:{value:switchState}"></div>

The current widget state is specified by the value configuration option. Declare an observable variable and pass it to the value option to update the variable value each time a switch state changes.

JavaScript
var switchState = ko.observable(false);
See Also
  • To learn how to create widgets in detail, refer to the Create a Widget article.
  • The dxSwitch widget is related to the Editors category. So read an overview of the features that are common for editors in the Common Tasks topic of the Editors article.
Show Example:
jQuery

Configuration

An object defining configuration options for the dxSwitch widget.

Methods

This section describes methods that can be used to manipulate a widget.

Events

This section describes events fired by this component.