The mobile Switch widget is used to display two exclusive choices.
When initialized, it shows the currently selected value. User slides the control to reveal the second value.
The mobile Switch can be created from input
element of type checkbox
.
The Kendo Mobile Application will automatically initialize a mobile Switch for every element with role
data attribute set to swtich
present in the views/layouts markup.
Alternatively, it can be initialized using jQuery plugin syntax in the containing mobile View init event handler.
<input type="checkbox" data-role="switch" />
<input type="checkbox" id="switch" />
<script>
var switchWidget = $("#switch").kendoMobileSwitch();
</script>
The checked state of the mobile Switch depends on the checked
property of the widget's constructor options
or the checked
attribute of the widget's element.
input
<input type="checkbox" id="switch" checked="checked" />
<script>
var switchWidget = $("#switch").kendoMobileSwitch();
</script>
<input type="checkbox" id="switch" />
<script>
var switchWidget = $("#switch").kendoMobileSwitch({ checked: true });
</script>
<input type="checkbox" id="switch" />
<script>
var switchWidget = $("#switch").kendoMobileSwitch({ onLabel: "YES", offLabel: "NO" });
</script>