@@ -54,21 +54,24 @@ var baseClasses = "ui-button ui-widget ui-corner-all",
5454
5555$ . widget ( "ui.checkboxradio" , {
5656 version : "@VERSION" ,
57- defaultElement : "<input type='checkbox'>" ,
5857 options : {
5958 disabled : null ,
6059 label : null ,
6160 icon : false
6261 } ,
6362
6463 _getCreateOptions : function ( ) {
65- var options = { } ;
64+ var disabled ,
65+ options = { } ;
6666
6767 this . _readLabel ( ) ;
6868
6969 this . originalLabel = this . label . html ( ) ;
7070
71- this . _readDisabled ( options ) ;
71+ disabled = this . element . prop ( "disabled" ) ;
72+ if ( disabled != null ) {
73+ options . disabled = disabled ;
74+ }
7275
7376 if ( this . originalLabel ) {
7477 options . label = this . originalLabel ;
@@ -95,13 +98,9 @@ $.widget( "ui.checkboxradio", {
9598 formElement . off ( "reset" + this . eventNamespace , formResetHandler ) ;
9699 formElement . on ( "reset" + this . eventNamespace , formResetHandler ) ;
97100
98- // If the option is a boolean its been set by either user or by
99- // _getCreateOptions so we need to make sure the prop matches
100- // If it is not a boolean the user set it explicitly to null so we need to check the dom
101- if ( typeof this . options . disabled === "boolean" ) {
102- this . element . prop ( "disabled" , this . options . disabled ) ;
103- } else {
104- this . _readDisabled ( this . options ) ;
101+ // If it is null the user set it explicitly to null so we need to check the dom
102+ if ( this . options . disabled == null ) {
103+ this . options . disabled = this . element . prop ( "disabled" ) || false ;
105104 }
106105
107106 // If the option is true we call set options to add the disabled
@@ -133,12 +132,12 @@ $.widget( "ui.checkboxradio", {
133132 } ,
134133
135134 _readLabel : function ( ) {
136- var ancestor , labelSelector ,
137- labels = this . element [ 0 ] . labels ;
138-
135+ var ancestor , labelSelector , parent = this . element . closest ( "label" ) ;
139136 // Check control.labels first
140- if ( labels !== undefined && labels . length > 0 ) {
141- this . label = $ ( labels [ 0 ] ) ;
137+ if ( this . element [ 0 ] . labels !== undefined && this . element [ 0 ] . labels . length > 0 ) {
138+ this . label = $ ( this . element [ 0 ] . labels [ 0 ] ) ;
139+ } else if ( parent . length > 0 ) {
140+ this . label = parent ;
142141 } else {
143142
144143 // We don't search against the document in case the element
@@ -241,6 +240,8 @@ $.widget( "ui.checkboxradio", {
241240
242241 if ( this . type === "checkbox" ) {
243242 toAdd += checked ? "ui-icon-check" : "ui-icon-blank" ;
243+ } else {
244+ toAdd += "ui-icon-blank" ;
244245 }
245246 this . icon . addClass ( toAdd ) . appendTo ( this . label ) ;
246247 } else if ( this . icon !== undefined ) {
0 commit comments