Ticket #4647 (closed bug: fixed)

Opened 5 years ago

Last modified 4 years ago

setDate cannot be called multiple times

Reported by: babaker Owned by:
Priority: major Milestone: 1.8
Component: ui.datepicker Version: 1.7.2
Keywords: datepicker setDate Cc:
Blocking: Blocked by:

Description

It is only possible to call setDate once. Any subsequent calls are ignored and the calendar does not refresh. For example, on any of the datepicker demos, type the following in the firebug console:

$("#datepicker").datepicker("setDate","+1m");

The calendar will change as expected (in this case it went from June to July). But if you call that function again, nothing will happen. Interestingly, if you setDate "-1m", it will jump all the way back to the month previous to the month that was initially displayed on the page (in my case it went all the way from July to May).

The workaround for this is to use the following which appears to work fine: $.datepicker._adjustdate("#datepicker",+1,"M");

Change History

comment:1 Changed 5 years ago by kbwood

The current setDate implementation calculates all relative settings from today, not the currently selected date. So all your calls are working it's just that they're all resulting in the same date. Maybe we need to enhance the relative date string to indicate using the current date rather than today: 'c -1m'?

comment:2 Changed 5 years ago by joern.zaefferer

  • Milestone changed from TBD to 1.8

comment:3 Changed 5 years ago by kbwood

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in r2955. As suggested, relative date string may begin with a 'c' to be relative to the currently selected date (or today if none selected) rather than the default of today.

Note: See TracTickets for help on using tickets.