]> source.dussan.org Git - jquery-ui.git/commitdiff
Datepicker: Handle changes to the disabled option. Fixes #8883 - Datepicker: Changing...
authorScott González <scott.gonzalez@gmail.com>
Wed, 5 Dec 2012 15:38:31 +0000 (10:38 -0500)
committerScott González <scott.gonzalez@gmail.com>
Wed, 5 Dec 2012 15:38:31 +0000 (10:38 -0500)
tests/unit/datepicker/datepicker_options.js
ui/jquery.ui.datepicker.js

index 8b8888780cab3751f71b7cb5c9ee8681afe8aba0..4b09face5871654bd33dfc70fafe51cdff8b1ed5 100644 (file)
@@ -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'),
index 9f480bf380cd91d48335a4a922e64a7dc50d13fa..4ab1fa201bd609057bd1ffcbe48497f893ea0bc1 100644 (file)
@@ -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);