vsn4ik / bootstrap-checkbox

A checkbox component based on Bootstrap framework.
https://vsn4ik.github.io/bootstrap-checkbox/
MIT License
213 stars 61 forks source link

Feature Request: Disable addon for specific checkboxes #43

Open Maelstorm1973 opened 3 years ago

Maelstorm1973 commented 3 years ago

I would like a feature to disable this addon for specific checkboxes. Something like data-check-disable="true" within the input element would do nicely.

Maelstorm1973 commented 3 years ago

After poking around in the code, I got it to work. And it works quite nicely. This code has three new options you can add. The first one sets on demand mode. With on demand mode, only checkboxes which has the data-switch-enable="true" attribute will show the switch. With on-demand mode turned off (the default), it works normally, but can be turned off for individual controls by adding the attribute data-switch-disable="true".

To turn on the new On-Demand feature:

$(':checkbox').checkboxpicker({
    onDemand: true,
});

To turn off the switch for one control when On Demand is off... <input type="checkbox" data-switch-disable="true">

To turn on the switch for one control when On Demand is on... <input type="checkbox" data-switch-enable="true">

Hopefully, someone will find this useful. bootstrap-checkbox.txt

rodrigomoncayo commented 3 years ago

Yes ! Your code that I just downloaded from the txt is exactly what I needed, and my requirement was fully satisfied.

Thank you and have a great day