Skip to content
Permalink
Browse files

Checkboxradio: use control.labels if defined

Fixes #9541
  • Loading branch information...
arschmitz committed Mar 7, 2014
1 parent d344b50 commit d903e1aa14e884d4d45fb1effeecd97d9e231fd2
Showing with 17 additions and 11 deletions.
  1. +17 −11 ui/checkboxradio.js
@@ -120,20 +120,26 @@ $.widget( "ui.checkboxradio", {

_getLabel: function() {
var ancestor, labelSelector;

// we don't search against the document in case the element
// is disconnected from the DOM
ancestor = this.element.parents().last();
labelSelector = "label[for='" + this.element.attr("id") + "']";
this.label = ancestor.find( labelSelector );
if ( !this.label.length ) {
ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
this.label = ancestor.filter( labelSelector );

// Check control.labels first
if ( this.element[ 0 ].labels !== undefined ){
this.label = $( this.element[ 0 ].labels );
console.log( this.element[ 0 ].labels );
} else {

// we don't search against the document in case the element
// is disconnected from the DOM
ancestor = this.element.parents().last();
labelSelector = "label[for='" + this.element.attr("id") + "']";
this.label = ancestor.find( labelSelector );
if ( !this.label.length ) {
this.label = ancestor.find( labelSelector );
ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
this.label = ancestor.filter( labelSelector );
if ( !this.label.length ) {
this.label = ancestor.find( labelSelector );
}
}
}

},

_toggleClasses: function() {

0 comments on commit d903e1a

Please sign in to comment.
You can’t perform that action at this time.