From fe6bef16e40c6e1847f26e20630914c42a6fb8cf Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 11 Mar 2010 03:50:20 +0000 Subject: Button: Support elements that are disconnected from the DOM. Fixes #5246 - _determineButtonType does not work if a label for checkbox/radiobutton is not yet attached to the document. --- ui/jquery.ui.button.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index f387932c3..14b8a6504 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -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" ); -- cgit v1.2.3