Skip to content

Commit 4bdbab9

Browse files
committed
Merge pull request jquery#322 from kborchers/bug_5665
Datepicker: Added checks for the disabled option. Fixed #5665 - Datepicker: Disabled parameter doesn't work
2 parents 259638d + ab365be commit 4bdbab9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ui/jquery.ui.datepicker.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ function Datepicker() {
105105
altFormat: '', // The date format to use for the alternate field
106106
constrainInput: true, // The input is constrained by the current date format
107107
showButtonPanel: false, // True to show button panel, false to not show it
108-
autoSize: false // True to size the input for the date format, false to leave as is
108+
autoSize: false, // True to size the input for the date format, false to leave as is
109+
disabled: false // The initial disabled state
109110
};
110111
$.extend(this._defaults, this.regional['']);
111112
this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'));
@@ -194,6 +195,10 @@ $.extend(Datepicker.prototype, {
194195
});
195196
this._autoSize(inst);
196197
$.data(target, PROP_NAME, inst);
198+
//If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
199+
if( inst.settings.disabled ) {
200+
this._disableDatepicker( target );
201+
}
197202
},
198203

199204
/* Make attachments based on settings. */
@@ -273,6 +278,10 @@ $.extend(Datepicker.prototype, {
273278
this._setDate(inst, this._getDefaultDate(inst), true);
274279
this._updateDatepicker(inst);
275280
this._updateAlternate(inst);
281+
//If disabled option is true, disable the datepicker before showing it (see ticket #5665)
282+
if( inst.settings.disabled ) {
283+
this._disableDatepicker( target );
284+
}
276285
inst.dpDiv.show();
277286
},
278287

0 commit comments

Comments
 (0)