Ticket #10910 (closed bug: invalid)
Radio button attribute set to checked doesn't update UI
| Reported by: | Aaron <spyhunter66@…> | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | attributes | Version: | 1.7.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Upgraded from 1.4.4 to 1.7.1 and this piece of code no longer works properly:
selectedProfile.SaveEmail ? $('#remEmailProfile').attr('checked', true) : $('#remEmailProfile').removeAttr('checked'); If my JSON value is set to true, it does add an attribute "checked"="checked" to the proper radio button in the html. However, the browser does not show the radio button as checked.
I tried using .prop("checked", true), but it doesn't appear to do anything.
Change History
comment:2 Changed 18 months ago by sindresorhus
- Status changed from new to closed
- Resolution set to invalid
Even though you should use .prop() to set the checked state, the .attr()method also works: http://jsfiddle.net/mofle/H453F/3/
Your testcase is set to using MooTools by the way, so no wonder why it's not working.
comment:3 Changed 18 months ago by sindresorhus
- Priority changed from undecided to low
- Component changed from unfiled to attributes
comment:4 Changed 18 months ago by Aaron <spyhunter66@…>
I'm sorry, I fixed my jsFiddle and the issue persists.
It also is shown on your example as well - the key issue is that any .removeAttr('checked') from 1 radio button appears to remove them from ALL.
But if you inspect the html, you'll see the checked=checked attribute is still in place, it's just not reflecting on the browser.
See my update: http://jsfiddle.net/H453F/5/
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

I narrowed it down more - it does work properly until a subsequent command is send to remove the checked attribute on a different radio button.
Here's a jFiddle: http://jsfiddle.net/H453F/1/