Bug Tracker

Opened 12 years ago

Closed 9 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 brandon)

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)

jqueryproblem.htm (811 bytes) - added by jimzim 12 years ago.
this is the correct file to refer to
1095.diff (489 bytes) - added by davidserduke 12 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 in reply to:  description Changed 12 years ago by jimzim

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.

Changed 12 years ago by jimzim

Attachment: jqueryproblem.htm added

this is the correct file to refer to

comment:2 Changed 12 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 12 years ago by brandon

Component: interfacefx
Description: modified (diff)
Milestone: 1.1.31.1.4
Owner: stefan deleted
Priority: majorminor
Version: 1.1.21.1.3

comment:4 Changed 12 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 12 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.

Changed 12 years ago by davidserduke

Attachment: 1095.diff added

comment:6 Changed 11 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 11 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 11 years ago by brandon

need: ReviewCommit
Owner: set to davidserduke

comment:9 Changed 11 years ago by brandon

Milestone: 1.1.41.2.2

comment:10 Changed 11 years ago by davidserduke

Resolution: fixed
Status: newclosed

Fixed in [3839].

comment:11 Changed 10 years ago by pkruithof

Resolution: fixed
Status: closedreopened

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 9 years ago by yehuda

Resolution: worksforme
Status: reopenedclosed

Can't reproduce on head. Added a test for animations.

Note: See TracTickets for help on using tickets.