@@ -89,16 +89,6 @@ $.widget( "ui.checkboxradio", {
89
89
return options ;
90
90
} ,
91
91
92
- _readDisabled : function ( options ) {
93
- var isDisabled = this . element . prop ( "disabled" ) ;
94
-
95
- if ( isDisabled !== undefined ) {
96
- options . disabled = isDisabled ;
97
- } else {
98
- options . disabled = false ;
99
- }
100
- } ,
101
-
102
92
_create : function ( ) {
103
93
var formElement = $ ( this . element [ 0 ] . form ) ;
104
94
@@ -107,17 +97,10 @@ $.widget( "ui.checkboxradio", {
107
97
formElement . off ( "reset" + this . eventNamespace , formResetHandler ) ;
108
98
formElement . on ( "reset" + this . eventNamespace , formResetHandler ) ;
109
99
110
- // If it is null the user set it explicitly to null so we need to check the DOM
111
100
if ( this . options . disabled == null ) {
112
101
this . options . disabled = this . element . prop ( "disabled" ) || false ;
113
102
}
114
103
115
- // If the option is true we call set options to add the disabled
116
- // classes and ensure the element is not focused
117
- if ( this . options . disabled === true ) {
118
- this . _setOption ( "disabled" , true ) ;
119
- }
120
-
121
104
this . _readType ( ) ;
122
105
123
106
this . _enhance ( ) ;
@@ -141,7 +124,9 @@ $.widget( "ui.checkboxradio", {
141
124
} ,
142
125
143
126
_readLabel : function ( ) {
144
- var ancestor , labelSelector , parent = this . element . closest ( "label" ) ;
127
+ var ancestor , labelSelector ,
128
+ parent = this . element . closest ( "label" ) ;
129
+
145
130
// Check control.labels first
146
131
if ( this . element [ 0 ] . labels !== undefined && this . element [ 0 ] . labels . length > 0 ) {
147
132
this . label = $ ( this . element [ 0 ] . labels [ 0 ] ) ;
@@ -158,8 +143,8 @@ $.widget( "ui.checkboxradio", {
158
143
this . label = ancestor . find ( labelSelector ) ;
159
144
if ( ! this . label . length ) {
160
145
161
- // The label was not found make sure ancestors exist if they do check their siblings
162
- // if they dont check the elements siblings
146
+ // The label was not found, make sure ancestors exist. If they do check their
147
+ // siblings, if they dont check the elements siblings
163
148
ancestor = ancestor . length ? ancestor . siblings ( ) : this . element . siblings ( ) ;
164
149
165
150
// Check if any of the new set of ancestors is the label
@@ -168,6 +153,9 @@ $.widget( "ui.checkboxradio", {
168
153
169
154
// Still not found look inside the ancestors for the label
170
155
this . label = ancestor . find ( labelSelector ) ;
156
+ if ( this . label . length === 0 ) {
157
+ $ . error ( "No label found for checkboxradio widget" ) ;
158
+ }
171
159
}
172
160
}
173
161
}
@@ -176,6 +164,7 @@ $.widget( "ui.checkboxradio", {
176
164
_enhance : function ( ) {
177
165
var checked = this . element . is ( ":checked" ) ;
178
166
167
+ this . _setOption ( "disabled" , this . options . disabled ) ;
179
168
this . _updateIcon ( checked ) ;
180
169
this . element . addClass ( "ui-helper-hidden-accessible " +
181
170
this . _classes ( "ui-checkboxradio" ) ) ;
0 commit comments