r3586 committed - Buttons: proper handling for radio buttons not contained in a form.

r3586 committed - Buttons: proper handling for radio buttons not contained in a form.

Revision: 3586
Author: scott.gonzalez
Date: Sat Jan 2 07:27:30 2010
Log: Buttons: proper handling for radio buttons not contained in a form.
http://code.google.com/p/jquery-ui/source/detail?r=3586
Modified:
/branches/dev/ui/jquery.ui.button.js
=======================================
--- /branches/dev/ui/jquery.ui.button.js    Sat Jan 2 03:54:14 2010
+++ /branches/dev/ui/jquery.ui.button.js    Sat Jan 2 07:27:30 2010
@@ -70,13 +70,27 @@
                    self.element
                        .attr("checked", true)
                        .click();
-                    // restrict search for the other buttons to the form, if present
-                    $('[name=' + self.element.attr('name') + ']', self.element[0].form ||
document)
-                        .not(self.element)
-                        .map(function() {
-                            return $(this).button('widget')[0];
-                        })
-                        .removeClass('ui-state-active');
+
+                    var radio = self.element[0],
+                        name = radio.name,
+                        form = radio.form,
+                        radios;
+                    if (name) {
+                        if (form) {
+                            radios = $(form).find('[name=' + name + ']');
+                        } else {
+                            radios = $('[name=' + name + ']', radio.ownerDocument)
+                                .filter(function() {
+                                    return !this.form;
+                                });
+                        }
+                        radios
+                            .not(radio)
+                            .map(function() {
+                                return $(this).button('widget')[0];
+                            })
+                            .removeClass('ui-state-active');
+                    }
                });
            break;
            default:
--