-
-
Notifications
You must be signed in to change notification settings - Fork 78.8k
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
Added styles to enable input state toggle buttons #2284
Conversation
Instead of placing the input and label as siblings, make the label wrap the checkbox. Less CSS that way. |
@markdotto this screw the whole point of relying only on css? There's no such selector as label:contains(input:checked)... |
Ah, yes, sorry—forgot about that for the checked state. That said, how do you see this working in IE7? Don't think that selector works there either. Can you double check all supported browsers? |
Looking at this again, we can't merge it in since |
What about using $(document).on('change', 'input:radio, input:checkbox', function(){
if (this.checked) $(this).attr('checked', 'checked');
else $(this).removeAttr('checked');
}); |
Sure, give it a go. Unsure if IE7/8 will support [checked], but I think it will if I recall. Are you able to test IE7/8/9? |
I've got a VM with IE7, I'll make sure it works on that awesome browser. I think IE7 has attribute support so it should work. Some one will have to confirm it works for IE8 since I can't get my hands on it without updating the one in my VM, it should already work with IE9. |
Never mind, I can't get it to work on IE7 nor IE8... it seems like the It's sad but I think the web is not yet ready for this. Curse you IE. |
I'm working on a project that would benefit from this, after a little trial and error I have a version that works for me in IE7 with a few modifications. To get around the For the working example view: http://jsfiddle.net/kwilliams_texstarweb/sfnY5/ |
@kwilliams Whoa great idea! I gave up too early :D Do you think you can bundle this as a new pull request? If you need help with this maybe I can help. |
After a little more fiddling the link below seems to perform well in all of my tests. Now all we need to find is an elegant way to fit this into bootstrap-buttons.js. Any thoughts? http://jsfiddle.net/kwilliams_texstarweb/B6nqw/12/ @charettes I'd be happy to put together a pull request, but it will probably be this weekend until I can get to it. |
I think it would be great if this |
I was able to clean this up quite a bit by iterating through label buttons toggling actives and then binding the change event. I think its ready... Thoughts? |
Maybe not the right place for this - but I just wanted to say thanks for doing this work - for me, the radio button groups are only useful if attached to an input element. @charettes css only solution is very nice. And almost certainly not the right place for this, but for the past 3 months IE7 is around 2% browser-share - even at the large slow corporation I work for they're at IE8. Maybe bootstrap 2.1 could drop IE7 support and the workarounds could be cleansed. |
The following styles allow usage of fully functional toggle buttons that rely on inputs instead of js to persist state. IMHO it's a semantically better way of defining toggle buttons.
Before writing any doc/examples I was eager to get some feedback about this approach.
A live example can be seen here http://jsfiddle.net/charettes/SauLj/.
This issue was discussed in #1161