Steven -

After doing some testing of my own, and looking through your code,
I've come to a similar conclusion. It only occurs when:
1) The item that you're hiding/showing is within a form.
2) The item that you're hiding/showing contains a checked radio button.
3) That radio button has a name applied to it.

It makes sense as to why it happens - as only one radio button can be
checked at a time. In total, the code to understand this can be
reduced to:

$("<input type=radio name=test checked>")
    .appendTo("body")
    .clone()
    .appendTo("body");

There'll be two radio buttons, but the second one will be the only one
that's checked.

I reduced your patch to adding the line:
    .find(":radio").removeAttr("checked").end()

I just committed it and it's in SVN rev 451. I'll wrap up 1.0.3
quickly then and get it out in the next couple days, that way you have
working code for your release.

--John

On 10/17/06, Steven Wittens <[EMAIL PROTECTED]> wrote:
> I've found a rather tricky bug in jQuery 1.0.2. When you use an
> animated slideDown() or show() on an element containing one or more
> radio buttons, the radio buttons lose their selection status in
> Firefox (1.5 and 2.0 for sure, maybe others), and Opera 9 (maybe
> others). It works fine in IE6 and Safari 2. This also only seems to
> happen when you apply an animation for the first time.
>
> I have attached a minimal test case to reproduce. There are four
> pairs of radiobuttons, each having one radio button selected. Their
> source markup is functionally identical. Clicking the provided link
> runs a different animation on each radio button pair: the first two
> pairs of radio buttons lose their selection, the last two work fine.
>
> This is caused by the code in jQuery.css() used to measure the
> dimensions of elements that are hidden. jQuery temporarily replicates
> the element inside its parent. This causes two selected radio buttons
> with the same 'name' to appear in the form, which is not allowed. It
> seems that Firefox and Opera defensively remove both selections in
> this case.
>
> One fix is to simply remove the checked attributes of all radio
> buttons inside the clone, before inserting it into the parent. See
> attached patch.
>
> This is a major blocker for jQuery in Drupal by the way, as it can
> break any animated portion of a form. I'm going to patch our included
> copy after you guys review this patch (we have a release candidate
> coming up next monday), but it would be nice to see this fixed in a
> 1.0.3 release soon ;).
>
> Steven Wittens
>
>
>
>
>
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>
>
>
>


-- 
John Resig
http://ejohn.org/
[EMAIL PROTECTED]

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to