Opened 12 years ago

Closed 9 years ago

#5419 closed bug (fixed)

Calling .datepicker("setDate") during onClose event reopens picker only in IE

Reported by: ladelfa Owned by:
Priority: minor Milestone: 1.8.17
Component: ui.datepicker Version: 1.8
Keywords: setDate onClose Cc:
Blocked by: Blocking:


Calling .datepicker("setDate") inside a onClose event behaves differently in IE7 and IE8 than it does in other browsers.

I tested FF 3.6.2 and Chrome 4.1.249 on WinXP. In those, the date gets set as the picker closes.

In IE 7 and 8 (also WinXP), the date gets set, but the picker reopens itself immediately.

  $(document).ready(function() {
      onClose: function(dateText, inst) {
        $('#picker').datepicker("setDate", new Date(2008,7,8));

<input id='picker' type='text'>

One workaround is to do the setDate after a timeout, but the behavior ought to be consistent across browsers.

Change History (7)

comment:1 Changed 12 years ago by kbwood

Why do you need to do this? Having selected a date you then change it to another value.

comment:2 Changed 11 years ago by john.firebaugh

I'm encountering this bug. The test case may look contrived, but there are legitimate reasons to call setDate inside onClose. In my case, I have two datepickers used for selecting a range of time, and one is changed, I may need to call setDate for both -- for example, to handle the case where the begin date is being set to a date later than the currently selected end date. In that situation the two dates need to be swapped in order to maintain the invariant that begin < end.

comment:3 Changed 11 years ago by sven_s

My workaround is to disable and to enable the datepicker:

$(this).datepicker('setDate', new Date(year1, month1, 1));

comment:4 Changed 11 years ago by Tom Van Schoor

Thanks for your workaround, i needed it for a month-year picker hack described at:

Ok it is for a hack, but it is pretty darn usefull.

comment:5 Changed 10 years ago by Jörn Zaefferer

Status: newopen

comment:6 Changed 9 years ago by Scott González

Milestone: TBD1.11.0

comment:7 Changed 9 years ago by tj.vantoll

Resolution: fixed
Status: openclosed

This was fixed by which was for #7686.

Version 1.8.16 which shows the bug - Version 1.8.17 which shows the bug is no longer present - Master, no problems -

Note: See TracTickets for help on using tickets.