-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
Toggle buttons don't honor [disabled] or .disabled #21237
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
Comments
X-Ref: #18874 (comment) |
This issue is fixed by adding custom code using jQuery Please check my solution here: http://jsbin.com/xoruzeqehi/edit?css,output I am attaching screen shot. Please let me know in case of any concerns/ queries |
The problem appears to be related to the initial state of the hidden checkbox as the btn initalizes. When the label in your example initializes as a button control, the checkbox value is automatically set as .active and [checked], although im not sure where in the bootstrap code this happens. A similar issue was posted and resolved 3 years ago where the inital state is not properly reflected. |
Also if you use a button instead of label, it appears to disable properly but the hidden checkbox still winds up with the initial state of active and checked |
Im wrong about the initial state. Some test code i added to your example was triggering an inital click that threw me off. I was still able to verify that if you change the label to a button it works as expected. |
PR : #22499 |
Uh oh!
There was an error while loading. Please reload this page.
There doesn't appear to be a clean way to disable a button state toggler. I've tried the following:
This button appears disabled but
.active
is added/removed when it is clicked and the checkbox's checked state is toggled.I have worked around this by listening for the
click
event and cancelling it if the<input>
is disabled, but I hoped that there would be a nicer way to accomplish this. If this behaviour is not a bug, consider this to be a feature request.The
.btn-danger
in the above test case exhibits the behaviour described. The.btn-success
is an example of the currently necessary workaround.This was encountered in Bootstrap v4.0.0-alpha.5.
The text was updated successfully, but these errors were encountered: