Skip to content

Commit

Permalink
Datepicker: Handle changes to the disabled option. Fixes #8883 - Date…
Browse files Browse the repository at this point in the history
…picker: Changing disabled option doesn't work.
  • Loading branch information
scottgonzalez committed Dec 5, 2012
1 parent 3c2acc3 commit 598cdae
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/unit/datepicker/datepicker_options.js
Expand Up @@ -48,6 +48,23 @@ test('option', function() {
'Get default settings');
});

test( "disabled", function() {
expect(8);
var inp = TestHelpers.datepicker.init('#inp');
ok(!inp.datepicker('isDisabled'), 'Initially marked as enabled');
ok(!inp[0].disabled, 'Field initially enabled');
inp.datepicker('option', 'disabled', true);
ok(inp.datepicker('isDisabled'), 'Marked as disabled');
ok(inp[0].disabled, 'Field now disabled');
inp.datepicker('option', 'disabled', false);
ok(!inp.datepicker('isDisabled'), 'Marked as enabled');
ok(!inp[0].disabled, 'Field now enabled');
inp.datepicker('destroy');

inp = TestHelpers.datepicker.init('#inp', { disabled: true });
ok(inp.datepicker('isDisabled'), 'Initially marked as disabled');
ok(inp[0].disabled, 'Field initially disabled');
})
test('change', function() {
expect( 12 );
var inp = TestHelpers.datepicker.init('#inp'),
Expand Down
7 changes: 7 additions & 0 deletions ui/jquery.ui.datepicker.js
Expand Up @@ -497,6 +497,13 @@ $.extend(Datepicker.prototype, {
if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
inst.settings.maxDate = this._formatDate(inst, maxDate);
}
if ( "disabled" in settings ) {
if ( settings.disabled ) {
this._disableDatepicker(target);
} else {
this._enableDatepicker(target);
}
}
this._attachments($(target), inst);
this._autoSize(inst);
this._setDate(inst, date);
Expand Down

0 comments on commit 598cdae

Please sign in to comment.