diff --git a/tests/unit/datepicker/datepicker_tickets.js b/tests/unit/datepicker/datepicker_tickets.js index 38c5e89f3..cf9dcbc5e 100644 --- a/tests/unit/datepicker/datepicker_tickets.js +++ b/tests/unit/datepicker/datepicker_tickets.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); diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index ffd20db2d..789afe1f1 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -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);