Detect whether switch is 'On' or 'Off'

4 posts, 0 answers
  1. Damien
    Damien avatar
    8 posts
    Member since:
    Jan 2013

    Posted 06 Feb 2013 Link to this post

    Hi Alexander/Telrik -

    I would like to know if there is a way to see if the switch is either checked or unchecked?

    Basically something like: ON || OFF

    if switch.OFF:then run this.function()
    If switch.NOT.OFF run that.function();


    I had a look at your examples on the demo page but only show a console.log("Checked?Unchecked")
    Which toggies with the switch but doesn't allow binding a specific event to the status of a switch.

    Thanks in advance.



  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 08 Feb 2013 Link to this post

    Hi Damien,

    Switch widget has a check method which allows you to get its state. Also it have a change event that fires when state of the widget changes.

    Regards,
    Alexander Valchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Gerardo
    Gerardo avatar
    1 posts
    Member since:
    Jun 2013

    Posted 13 Jun 2013 Link to this post

    Hi,
    I'm using the documentation you mentioned and I cannot get manage to make it work, I tried it in my current project and it didn't work, I also tried in a blank project with no luck either.

    I copy here the documentation of your event, and hope to get an answer soon.

    Thanks

    <input type="checkbox" id="switch" data-role="switch" />

    <script>
    $("#switch").data("kendoMobileSwitch").bind("change", function(e) {
    console.log(e.checked); // true or false
    }
    </script>
  5. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 14 Jun 2013 Link to this post

    Hi Gerardo,

    I prepared a small example where everything seems to work as expected.

    Please compare your implementation with the one presented in the sample.

    Regards,
    Alexander Valchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready