moris62
moris62

Reputation: 1045

how to enable a or disable a switch by check and unchecked a checkbox

I have a kendo switch which is disabled by default:

<input type="checkbox" id="notifications-switch" aria-label="Notifications Switch" disabled="disabled" />

i have a check box,which is unchecked by default,i want to enabled the switch by checking the checkbox,here is the check box:

 <input type="checkbox" id="eq1" class="k-checkbox"> 

here is what want but does not work,when i check it ,it does not enable the switch:

 $("#eq1").change(function () {
          if (this.checked) {
              $("#notifications-switch").is(":disabled") = false;
          }
      });

Upvotes: 1

Views: 2388

Answers (2)

moris62
moris62

Reputation: 1045

in kendo in order to achieve the enable disable the follwoing should be use(regarding my question):

 $("#notifications-switch").data("kendoMobileSwitch").enable(true);

Upvotes: 1

Bhushan Kawadkar
Bhushan Kawadkar

Reputation: 28513

try this:you need to use prop to disable the switch. you can use :checked value to make it disable or enabled

$("#eq1").change(function () {
     $("#notifications-switch").prop("disabled",!$(this).is(":checked"));
  });

Upvotes: 0

Related Questions