Skip to content

Commit d903e1a

Browse files
committed
Checkboxradio: use control.labels if defined
Fixes #9541
1 parent d344b50 commit d903e1a

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

ui/checkboxradio.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,26 @@ $.widget( "ui.checkboxradio", {
120120

121121
_getLabel: function() {
122122
var ancestor, labelSelector;
123-
124-
// we don't search against the document in case the element
125-
// is disconnected from the DOM
126-
ancestor = this.element.parents().last();
127-
labelSelector = "label[for='" + this.element.attr("id") + "']";
128-
this.label = ancestor.find( labelSelector );
129-
if ( !this.label.length ) {
130-
ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
131-
this.label = ancestor.filter( labelSelector );
123+
124+
// Check control.labels first
125+
if ( this.element[ 0 ].labels !== undefined ){
126+
this.label = $( this.element[ 0 ].labels );
127+
console.log( this.element[ 0 ].labels );
128+
} else {
129+
130+
// we don't search against the document in case the element
131+
// is disconnected from the DOM
132+
ancestor = this.element.parents().last();
133+
labelSelector = "label[for='" + this.element.attr("id") + "']";
134+
this.label = ancestor.find( labelSelector );
132135
if ( !this.label.length ) {
133-
this.label = ancestor.find( labelSelector );
136+
ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
137+
this.label = ancestor.filter( labelSelector );
138+
if ( !this.label.length ) {
139+
this.label = ancestor.find( labelSelector );
140+
}
134141
}
135142
}
136-
137143
},
138144

139145
_toggleClasses: function() {

0 commit comments

Comments
 (0)