]> source.dussan.org Git - jquery-ui.git/commitdiff
Button: Support elements that are disconnected from the DOM.
authorScott González <scott.gonzalez@gmail.com>
Thu, 11 Mar 2010 03:50:20 +0000 (03:50 +0000)
committerScott González <scott.gonzalez@gmail.com>
Thu, 11 Mar 2010 03:50:20 +0000 (03:50 +0000)
Fixes #5246 - _determineButtonType does not work if a label for checkbox/radiobutton is not yet attached to the document.

ui/jquery.ui.button.js

index f387932c352b6592aa7c162b0c71fb61f5067fee..14b8a65047934a5f3a4e8caf434ee23b9bb9793f 100644 (file)
@@ -158,7 +158,10 @@ $.widget( "ui.button", {
                                        : "button";
 
                if ( this.type === "checkbox" || this.type === "radio" ) {
-                       this.buttonElement = $( "[for=" + this.element.attr("id") + "]" );
+                       // we don't search against the document in case the element
+                       // is disconnected from the DOM
+                       this.buttonElement = this.element.parents().last()
+                               .find( "[for=" + this.element.attr("id") + "]" );
                        this.element.addClass('ui-helper-hidden-accessible');
 
                        var checked = this.element.is( ":checked" );