simontabor / jquery-toggles

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

'active' class on initialization #52

Closed adrienrn closed 9 years ago

adrienrn commented 9 years ago

On initialization of the toggle (when page loads), the toggle is initialized to the right value but it doesn't add the class active to the .toggle-on div.

Regardless of the on options passed to the .toggles() function, the .active class is always on the .toggle-off.

Reading the code, I think that's because the .toggle function is not called on init. A solution would be to set the right class at the end of the constructor based on the current active state:

self.els.off.toggleClass('active', !self['active']);
self.els.on.toggleClass('active', self['active']);
huseyinemanet commented 9 years ago

Is there any progress about this bug?

adrienrn commented 9 years ago

@huseyinemanet For now, the fix explained in my first post has been working for us.

simontabor commented 9 years ago

Sorry about the crazy delay, this was fixed back in https://github.com/simontabor/jquery-toggles/commit/33231f839805122d90fa40f476e2833359152594 though