I see $('.toggle-button') selector is used in the code, which means, that if the toggleButtons was called on a checkbox that's not yet inserted into DOM, it won't attach any event listeners.
What about doing smth like this instead?
+1, this matter a lot when using it with frameworks like backbone.
+1, I'm unable to get this to work with some knockoutjs when I use data-binds. More specifically with use of the "with" binding.
I like this idea. Can you send me a pull request?