simontabor / jquery-toggles

jQuery plugin to make easy toggle buttons
http://simontabor.com/labs/toggles
MIT License
362 stars 67 forks source link

Support disabled state #51

Closed EricGrange closed 9 years ago

EricGrange commented 9 years ago

One way would be through supporting a "disabled" attribute, which could be set/cleared by the jQuery attr() method as usual.

In toggle.js, the required changes are to add lines like

if (self.el.attr('disabled')) return;

in the beginning of the mousedown event & clickHandler methods.

Bare-bones styling for the disabled state can then be achieved with following rule

 div[disabled] > .toggle-slide {
     opacity: 0.5;
 }
justinlee34 commented 9 years ago

Hi Simon,

Just to check how do i disable the toggle button?

I tried: $("#checklistitem0").children().prop('disabled',true); or $('#checklistitem0').prop("disabled",true);

but failed.

Any advice will be good.

Thanks.

Regards, Justin