Skip to content
Permalink
Browse files

Datepicker: Fixed conflict between beforeShowDay and getDate

  • Loading branch information
Keith Wood
Keith Wood committed Jan 29, 2010
1 parent b144b76 commit f214b708894ef2a1607050977f9698cf0d916d43
Showing with 27 additions and 3 deletions.
  1. +22 −1 tests/unit/datepicker/datepicker_tickets.js
  2. +5 −2 ui/jquery.ui.datepicker.js
@@ -3,6 +3,27 @@
*/
(function($) {

module("datepicker: tickets");
module("datepicker: tickets", {
teardown: function() {
stop();
setTimeout(start, 13);
}
});

// http://forum.jquery.com/topic/several-breaking-changes-in-jquery-ui-1-8rc1
test('beforeShowDay-getDate', function() {
var inp = init('#inp', {beforeShowDay: function(date) { inp.datepicker('getDate'); return [true, '']; }});
var dp = $('#ui-datepicker-div');
inp.val('01/01/2010').datepicker('show');
equals($('div.ui-datepicker-title').text(), 'January 2010', 'Initial month');
$('a.ui-datepicker-next', dp).click();
$('a.ui-datepicker-next', dp).click();
equals($('div.ui-datepicker-title').text(), 'March 2010', 'After next clicks');
inp.datepicker('hide').datepicker('show');
$('a.ui-datepicker-prev', dp).click();
$('a.ui-datepicker-prev', dp).click();
equals($('div.ui-datepicker-title').text(), 'November 2009', 'After prev clicks');
inp.datepicker('hide');
});

})(jQuery);
@@ -603,6 +603,7 @@ $.extend(Datepicker.prototype, {
}
var beforeShow = $.datepicker._get(inst, 'beforeShow');
extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {}));
inst.lastVal = null;
$.datepicker._lastInput = input;
$.datepicker._setDateFromField(inst);
if ($.datepicker._inDialog) // hide cursor
@@ -1224,9 +1225,11 @@ $.extend(Datepicker.prototype, {

/* Parse existing date and initialise date picker. */
_setDateFromField: function(inst, noDefault) {
if (inst.input.val() == inst.lastVal) {
return;
}
var dateFormat = this._get(inst, 'dateFormat');
inst.lastVal = inst.input ? inst.input.val() : null;
var dates = inst.lastVal;
var dates = inst.lastVal = inst.input ? inst.input.val() : null;
var date, defaultDate;
date = defaultDate = this._getDefaultDate(inst);
var settings = this._getFormatConfig(inst);

0 comments on commit f214b70

Please sign in to comment.
You can’t perform that action at this time.