|
1 | 1 | /*
|
2 |
| -The jQuery UI Month Picker Version 3.0.2 |
| 2 | +The jQuery UI Month Picker Version 3.0.3 |
3 | 3 | https://github.com/KidSysco/jquery-ui-month-picker/
|
4 | 4 |
|
5 | 5 | Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
@@ -166,7 +166,7 @@ along with this program. If not, see
|
166 | 166 | }
|
167 | 167 |
|
168 | 168 | $.MonthPicker = {
|
169 |
| - VERSION: '3.0.1', // Added in version 2.4; |
| 169 | + VERSION: '3.0.3', // Added in version 2.4; |
170 | 170 | i18n: {
|
171 | 171 | year: 'Year',
|
172 | 172 | prevYear: 'Previous Year',
|
@@ -528,7 +528,7 @@ along with this program. If not, see
|
528 | 528 |
|
529 | 529 | Clear: function () {
|
530 | 530 | this.element.val('');
|
531 |
| - this._updateAlt(0, ''); |
| 531 | + $(this.options.AltField).val(''); |
532 | 532 | this._validationMessage.hide();
|
533 | 533 | },
|
534 | 534 |
|
@@ -648,10 +648,14 @@ along with this program. If not, see
|
648 | 648 | _setSelectedMonth: function (_selMonth) {
|
649 | 649 | var month = _encodeMonth(this, _selMonth), _el = this.element;
|
650 | 650 |
|
651 |
| - if (!month) { |
652 |
| - _el.val( '' ); |
| 651 | + if (month) { |
| 652 | + var date = new Date( _toYear(month), month % 12, 1 ); |
| 653 | + _el.val( this._formatMonth( date ) ); |
| 654 | + |
| 655 | + this._updateAlt(0, date); |
| 656 | + this._validationMessage.hide(); |
653 | 657 | } else {
|
654 |
| - _el.val( this._formatMonth( new Date( _toYear(month), month % 12, 1)) ); |
| 658 | + this.Clear(); |
655 | 659 | }
|
656 | 660 |
|
657 | 661 | this._ajustYear(this.options);
|
@@ -840,11 +844,15 @@ along with this program. If not, see
|
840 | 844 | this._titleButton.jqueryUIButton({ label: this._i18n('year') + ' ' + this._pickerYear });
|
841 | 845 | },
|
842 | 846 |
|
| 847 | + // When calling this method with a falsy (undefined) date |
| 848 | + // value, this.element.val() is used as the date value. |
| 849 | + // |
| 850 | + // Therefore it's important to update the input field |
| 851 | + // before calling this method. |
843 | 852 | _updateAlt: function (noop, date) {
|
844 |
| - // False means use the fields value. |
845 | 853 | var _field = $(this.options.AltField);
|
846 | 854 | if (_field.length) {
|
847 |
| - _field.val(this._formatMonth(date, this.options.AltFormat)); |
| 855 | + _field.val( this._formatMonth(date, this.options.AltFormat) ); |
848 | 856 | }
|
849 | 857 | },
|
850 | 858 |
|
|
0 commit comments