Ticket #1095 (closed bug: worksforme)
Hiding/showing div clears radio checks
| Reported by: | jimzim | Owned by: | davidserduke |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.2.2 |
| Component: | effects | Version: | 1.1.3 |
| Keywords: | radio checked show hide unchecked | Cc: | |
| Blocking: | Blocked by: |
Description (last modified by brandon) (diff)
Hi,
I'm running into a problem where hiding/showing a div clears all checked radios within that div.
I reduced the problem code down to the bare minimum to still exhibit the problem. It's attached, or try it out at http://www.thatphonecall.com/jqueryproblem.htm
Is this behavior expected? If so, wouldn't it be more intuitive for show/hide to not clear the checks in radios?
I'm experiencing this problem in IE 6.0.2900.2180...
Thanks, Jim
Attachments
Change History
comment:1 in reply to: ↑ description Changed 6 years ago by jimzim
Changed 6 years ago by jimzim
-
attachment
jqueryproblem.htm
added
this is the correct file to refer to
comment:2 Changed 6 years ago by malsup
Note that the problem goes away when animation is removed. This works:
$('#hiddenpart').show();
Alerting the 'checked' property of the input shows that it changes from 'true' before the animation to 'undefined' afterwards.
comment:3 Changed 6 years ago by brandon
- Description modified (diff)
- Component changed from interface to fx
- Priority changed from major to minor
- Version changed from 1.1.2 to 1.1.3
- Milestone changed from 1.1.3 to 1.1.4
- Owner stefan deleted
comment:4 Changed 6 years ago by NatalieMac
This problem is happening in both IE6 and IE7. It happens when any kind of animation is used to show the container of the radio buttons, but not until the second time the container is shown. Animation to hide the div doesn't affect the checked state of the radio buttons.
comment:5 Changed 6 years ago by davidserduke
The problem here appears to be caused when jQuery.css() clones the node and adds it to the form. The code removes the "checked" attribute, but not the "defaultChecked" one. I guess IE decides to check it when it is appeneded if the defaultChecked is set. Adding a removeAttr("defaultChecked") on all radio buttons seems to work at least for this test case.
I'll attach a patch.
comment:6 Changed 6 years ago by saturnflyer
I have not applied the attached patch, so take this with a grain of salt...
I did a dirty test of this by applying removeAttr("defaultChecked") to input:radio and reset buttons no longer function properly.
comment:7 Changed 6 years ago by davidserduke
Actually if you look closer at the code, the removeAttr("defaultChecked") call is not supposed to be on the actual radio buttons but just on the cloned ones. These cloned ones are just used to get the width/height of the element while it is hidden. So reset will work just fine.
comment:8 Changed 6 years ago by brandon
- need changed from Review to Commit
- Owner set to davidserduke
comment:10 Changed 6 years ago by davidserduke
- Status changed from new to closed
- Resolution set to fixed
Fixed in [3839].
comment:11 Changed 4 years ago by pkruithof
- Status changed from closed to reopened
- Resolution fixed deleted
This bug is active again in version 1.3.2: performing the test case on a default IE7 setup (not the compatibility view in IE8) leaves both radio buttons unchecked.
comment:12 Changed 4 years ago by yehuda
- Status changed from reopened to closed
- Resolution set to worksforme
Can't reproduce on head. Added a test for animations.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Whoops. I left a critical line (line 12) commented out in the attachment. Please disregard the first attachment, and refer only to the 2nd one.