Reset Switch back to original value

2 posts, 0 answers
  1. Ezequiel
    Ezequiel avatar
    44 posts
    Member since:
    Oct 2011

    Posted 06 Sep Link to this post

    Before version 2019.2 I used MobileSwitch for checkboxes and when I want to clear a form I did this:

    1._form.reset();
    2.$(_form).find("[type=checkbox]").each(function () {
    3.      $("#" + this.id).data("kendoMobileSwitch").refresh();
    4.})

     

    Now, using Switch, I've changed line 3 to

    $("#" + this.id).data("kendoSwitch").refresh();

    but that didn't work.

     

    How can I achieve the same with new Switch?

  2. Ezequiel
    Ezequiel avatar
    44 posts
    Member since:
    Oct 2011

    Posted 09 Sep in reply to Ezequiel Link to this post

    I solved with a workaround

    1._form.reset();
    2.$(_form).find("[type=checkbox]").each(function () {
    3.     var _switch = $("#" + this.id).data("kendoSwitch");
    4.     $("#" + this.id).data("kendoSwitch").value(_switch.element[0].defaultValue)
    5.})

     

Back to Top