6

I am trying to use a Kendo mobile widget - switch in my web application as below:

enter image description here

<input id="btnConvert" type="checkbox" onclick="onChange();" />

 $(document).ready()
    {        
        $("#btnConvert").kendoMobileSwitch({
            onLabel: "UK",
            offLabel: "US"
        });        
    }
    function onChange(e) {
        alert(e.checked);//true of false
    }

But its not firing the click event. i tried the onchange event which is also not working.

Also i tried

    $('input:checkbox').change(function () {
}

but no success...

OnaBai
  • 40,767
  • 6
  • 96
  • 125
sony
  • 1,453
  • 3
  • 35
  • 79

1 Answers1

6

Define a change handler event in your switch definition.

$("#btnConvert").kendoMobileSwitch({
    onLabel: "UK",
    offLabel: "US",
    change : function (e) {
        alert("You changed the value");
    }
}); 

See the documentation here.

OnaBai
  • 40,767
  • 6
  • 96
  • 125
  • Hi OnaBai, many thanks for your answer. I follow many of your answers and your name is very popular StackOverflow... – sony Jul 28 '14 at 17:29
  • I have another unsolved mystery which i posted a few weeks ago : http://stackoverflow.com/questions/24166750/kendo-ui-chart-not-resizing , i couldnt find a solution to that yet... – sony Jul 28 '14 at 17:34
  • Can you reproduce it in a JSFiddle? Seems to be related with the order on how things happen (first drawing and the sizing the container) – OnaBai Jul 28 '14 at 17:36