Switch

A switch widget.

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

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

You can create a widget using one of the following approaches.

  • jQuery
    Use the dxSwitch jQuery plug-in.

    HTML
    <div id="switch"></div>
    JavaScript
    $("#switch").dxSwitch({
        onText: 'On',
        offText: 'Off',
        value: true
    });
  • Knockout
    Add a div element and apply the dxSwitch binding to this element.

    HTML
    <div data-bind="dxSwitch: {
        onText: 'On',
        offText: 'Off',
        value: true
    }"></div>
  • Angular
    Add a div element and apply the dx-switch directive to this element.

    HTML
    <div dx-switch="{
        onText: 'On',
        offText: 'Off',
        value: true
    }"></div>

Note that DevExtreme widgets require you to link the jQuery and Globalize libraries to your application. If you use the Knockout or Angular approach, the Knockout or Angular library is also required.

See Also

You can find detailed information on the principles of working with the widget in the dxSwitch section of the Editor Widgets article.

View Demo

Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the dxSwitch widget.

Methods

This section describes the members used to manipulate the widget.

Events

This section describes events exposed by this widget.