vendredi 18 septembre 2015

Bootstrap Toggle: Setting the toggle state of multiple checkbox to 'Off'

I am using Bootstrap Toggle plugin which converts checkboxes into toggle buttons.

<input type="checkbox" id="c1" data-toggle="toggle" data-on="Enabled" data-off="Disabled" data-size="small" data-onstyle="success">
<input type="checkbox" id="c2" data-toggle="toggle" data-on="Style" data-off="Style" data-size="small" data-onstyle="success">
<input type="checkbox" id="c3" data-toggle="toggle" data-on="Border" data-off="Border" data-size="small" data-onstyle="success">

Its working well but having problem in turning the state of checkbox to off/unchecked.

just like we use on checkbox:

$("#c1,#c2,#c3").prop('checked', false);

As per documentation Bootstrap Toggle plugin use function "Off" to turn off But this is not working:

$("#c1,#c2,#c3").bootstrapToggle('off');

whereas

$("#c1,#c2,#c3").bootstrapToggle('disable');

works & disable all the three checkboxes.

But i dnt want to disable, just turn off all the toggle buttons programmatically. Tried with each separate line of code:

$("#c1").bootstrapToggle('off'); 
$("#c2").bootstrapToggle('off');
$("#c3").bootstrapToggle('off');

But only One (1st element) get turned off & my next script stops after that.

there is some bug in the plugin ? or something wrong in my code !




Aucun commentaire:

Enregistrer un commentaire