-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
switchState doesn't trigger when indeterminate is set #426
Comments
+1, exact same problem found and came here to report it. Thanks for the fiddle. Might see if I can fix it and pull request. |
@cristalembalagens Set the state option to null when using indeterminate. Then the event will trigger. For more info see here: https://github.com/nostalgiaz/bootstrap-switch/blob/master/dist/js/bootstrap-switch.js#L499 The plugin catches the event and only retriggers it if it has changed. Updated fiddle: http:https://jsfiddle.net/2m4b4bb2/3/ |
@rfox90 great solution. The only different thing I had to do is to initiate those checkboxes without indeterminate with the normal initiation and those with indeterminate with {state:null}. Using data-state=null didn't work. There's still a problem, once you set a value, if you need to turn it to indeterminate again, you can't set state to null again. |
👍 @rfox90's solution worked for now. |
I ran into this as well. @cristalembalagens: You can set the state after the initialization -- in particular, whenever you set the switch to indeterminate -- using something along the following lines: element.data('bootstrap-switch').options.state = null; // or anything else other than true and false As another side note, the line that is responsible for this bug should be linked more permanently like this: https://github.com/nostalgiaz/bootstrap-switch/blob/a39a1e/dist/js/bootstrap-switch.js#L530 |
If the initial state is not checked and data-indeterminate is true, when the button is hit on the off side it becomes on and triggers the switchState event, but if you hit on the on side, it becomes off and doesn't trigger the switchState event because it was already off but, it was set to be in indeterminate state so the event must consider that the state is not checked or unchecked.
Here's a fiddle to explain this case http:https://jsfiddle.net/2m4b4bb2/
The text was updated successfully, but these errors were encountered: