Kendo Mobile Switch

by kendomobile

HTML

<script src="https://getfirebug.com/firebug-lite.js"></script>
<script src="http://cdn.kendostatic.com/2013.2.716/js/kendo.all.min.js"></script>
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.2.716/styles/kendo.mobile.all.min.css">
<!-- Demo created for the book: Building Mobile Applications Using Kendo UI Mobile and ASP.NET Web API.
http://www.packtpub.com/building-mobile-applications-with-kendoui-html5/book -->
<div data-role="view" data-init="init">
    <div>
    <label> Data Attribute: </label>   
        <input type="checkbox" id="chkSwitch1"
               data-role="switch" checked="checked"
               data-on-label="Pass" data-off-label="Fail"
               data-change="switchChange"/>
    </div>
    <div>
        <label> Plugin syntax: </label>
        <input type="checkbox" id="chkSwitch2"  />               
    </div>
    <br/>
     <div id="output"> </div>
</div>

JavaScript

var app = new kendo.mobile.Application(document.body);
function init(){
    $('#chkSwitch2').kendoMobileSwitch({
                checked:false,
                onLabel:'Yes',
                offLabel:'No',
                change: switchChange
    });   
}

function switchChange(e){
    output('Selected Text: ' + e.checked ? e.sender.options.onLabel : e.sender.options.offLabel );       
}

function output(data){
    $("#output").append(data);
    $("#output").append("<br/>");    
}