Datepicker: Fixed #4804 onChangeMonthYear fires at first run

This commit is contained in:
Keith Wood 2010-01-10 04:54:12 +00:00
parent 6047f99ec4
commit c14e958966

View File

@ -259,7 +259,7 @@ $.extend(Datepicker.prototype, {
return this._get(inst, key); return this._get(inst, key);
}); });
$.data(target, PROP_NAME, inst); $.data(target, PROP_NAME, inst);
this._setDate(inst, this._getDefaultDate(inst)); this._setDate(inst, this._getDefaultDate(inst), true);
this._updateDatepicker(inst); this._updateDatepicker(inst);
this._updateAlternate(inst); this._updateAlternate(inst);
}, },
@ -1302,7 +1302,7 @@ $.extend(Datepicker.prototype, {
}, },
/* Set the date(s) directly. */ /* Set the date(s) directly. */
_setDate: function(inst, date) { _setDate: function(inst, date, noChange) {
var clear = !(date); var clear = !(date);
var origMonth = inst.selectedMonth; var origMonth = inst.selectedMonth;
var origYear = inst.selectedYear; var origYear = inst.selectedYear;
@ -1310,7 +1310,7 @@ $.extend(Datepicker.prototype, {
inst.selectedDay = inst.currentDay = date.getDate(); inst.selectedDay = inst.currentDay = date.getDate();
inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth(); inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth();
inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear(); inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear();
if (origMonth != inst.selectedMonth || origYear != inst.selectedYear) if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
this._notifyChange(inst); this._notifyChange(inst);
this._adjustInstDate(inst); this._adjustInstDate(inst);
if (inst.input) { if (inst.input) {