aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.button.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/jquery.ui.button.js')
-rw-r--r--ui/jquery.ui.button.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js
index 134dae3d3..9cf8974b2 100644
--- a/ui/jquery.ui.button.js
+++ b/ui/jquery.ui.button.js
@@ -201,8 +201,16 @@ $.widget( "ui.button", {
if ( this.type === "checkbox" || this.type === "radio" ) {
// we don't search against the document in case the element
// is disconnected from the DOM
- this.buttonElement = this.element.parents().last()
- .find( "label[for=" + this.element.attr("id") + "]" );
+ var ancestor = this.element.parents().last(),
+ labelSelector = "label[for=" + this.element.attr("id") + "]";
+ this.buttonElement = ancestor.find( labelSelector );
+ if ( !this.buttonElement.length ) {
+ ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
+ this.buttonElement = ancestor.filter( labelSelector );
+ if ( !this.buttonElement.length ) {
+ this.buttonElement = ancestor.find( labelSelector );
+ }
+ }
this.element.addClass( "ui-helper-hidden-accessible" );
var checked = this.element.is( ":checked" );