How to refresh the switchery checkbox that is already being initialized?

490 views Asked by At

I've initialized the switchery using the below code.

var ss_is_schedule_edit = document.querySelector('.ss_is_schedule_edit');
var mySwitch = new Switchery(ss_is_schedule_edit, { color: '#8360c3' });

And I couldn't able to check/uncheck the switchery using the below code. it didn't worked.

$('.switchery').trigger('click');

Also, I've tried the below code but couldn't help.

mySwitch.setPosition(true);

Can anyone help me with this?

1

There are 1 answers

0
Elavarsan Ganesan On

I solved my problem with switchery.

Here is the solutions:

You can simply remove the existing switchery section using the below code.

$('.switchery').remove();

Then, you can initialize the switchery again using the below code.

var ss_is_schedule_edit = document.querySelector('.ss_is_schedule_edit');
var mySwitch = new Switchery(ss_is_schedule_edit, { color: '#8360c3' });

Thanks.