Opened 13 years ago
Closed 10 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: |
Description
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.
<script> $(document).ready(function() { $('#picker').datepicker({ onClose: function(dateText, inst) { $('#picker').datepicker("setDate", new Date(2008,7,8)); } }); }); </script> <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 13 years ago by
comment:2 Changed 12 years ago by
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 12 years ago by
My workaround is to disable and to enable the datepicker:
$(this).datepicker('disable'); $(this).datepicker('setDate', new Date(year1, month1, 1)); $(this).datepicker('enable');
comment:4 Changed 12 years ago by
Thanks for your workaround, i needed it for a month-year picker hack described at: http://stackoverflow.com/questions/2208480/jquery-date-picker-to-show-month-year-only/6110670#6110670
Ok it is for a hack, but it is pretty darn usefull.
comment:5 Changed 11 years ago by
Status: | new → open |
---|
Reproduced in IE8: http://jsbin.com/irebap/edit#javascript,html
comment:6 Changed 10 years ago by
Milestone: | TBD → 1.11.0 |
---|
comment:7 Changed 10 years ago by
Milestone: | 1.11.0 → 1.8.17 |
---|---|
Resolution: | → fixed |
Status: | open → closed |
This was fixed by https://github.com/jquery/jquery-ui/commit/872387abd5ab59e00df108438ae5bba76df1138a which was for #7686.
Version 1.8.16 which shows the bug - http://jsfiddle.net/tj_vantoll/kHWpn/4/. Version 1.8.17 which shows the bug is no longer present - http://jsfiddle.net/tj_vantoll/kHWpn/5/. Master, no problems - http://jsfiddle.net/tj_vantoll/kHWpn/.
Why do you need to do this? Having selected a date you then change it to another value.