Opened 16 years ago
Closed 13 years ago
#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: | |
Blocked by: | Blocking: |
Description (last modified by )
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 (2)
Change History (14)
comment:1 Changed 16 years ago by
comment:2 Changed 16 years ago by
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 16 years ago by
Component: | interface → fx |
---|---|
Description: | modified (diff) |
Milestone: | 1.1.3 → 1.1.4 |
Owner: | stefan deleted |
Priority: | major → minor |
Version: | 1.1.2 → 1.1.3 |
comment:4 Changed 15 years ago by
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 15 years ago by
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.
Changed 15 years ago by
comment:6 Changed 15 years ago by
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 15 years ago by
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 15 years ago by
need: | Review → Commit |
---|---|
Owner: | set to davidserduke |
comment:9 Changed 15 years ago by
Milestone: | 1.1.4 → 1.2.2 |
---|
comment:11 Changed 13 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
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 13 years ago by
Resolution: | → worksforme |
---|---|
Status: | reopened → closed |
Can't reproduce on head. Added a test for animations.
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.