Skip to content
Permalink
Browse files
Datepicker: Handle clearing the date inside _setDate() as early as po…
…ssible. Fixes #6684 - Datepicker: setDate() should accept an empty string.

Thanks RobinHerbots.
  • Loading branch information
scottgonzalez committed Nov 22, 2010
1 parent a4d54b4 commit 7b523c2ec144fb0f4e39ad1c593453058fd3fb3a
Showing 1 changed file with 5 additions and 2 deletions.
@@ -1342,7 +1342,10 @@ $.extend(Datepicker.prototype, {

/* Set the date(s) directly. */
_setDate: function(inst, date, noChange) {
var clear = !(date);
if ( !date ) {
inst.input.val( "" );
return;
}
var origMonth = inst.selectedMonth;
var origYear = inst.selectedYear;
var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
@@ -1353,7 +1356,7 @@ $.extend(Datepicker.prototype, {
this._notifyChange(inst);
this._adjustInstDate(inst);
if (inst.input) {
inst.input.val(clear ? '' : this._formatDate(inst));
inst.input.val(this._formatDate(inst));
}
},

3 comments on commit 7b523c2

@pheiberg
Copy link
Contributor

@pheiberg pheiberg commented on 7b523c2 Nov 22, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional that this change breaks the onChangeMonthYear notification for null dates? In the previous version notifyChange would be called, but not in this.

@scottgonzalez
Copy link
Member Author

@scottgonzalez scottgonzalez commented on 7b523c2 Nov 22, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's not intentional. Thanks for catching this. I'll try to land a fix for both bugs, if I run into a problem, I'll just revert this.

@scottgonzalez
Copy link
Member Author

@scottgonzalez scottgonzalez commented on 7b523c2 Nov 22, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9ade710.

Please sign in to comment.