Skip to main content

Search and Top Navigation

#6225 open bug ()

Opened October 25, 2010 06:31PM UTC

Last modified July 14, 2014 07:09PM UTC

Datepicker: Inline datepicker and showCurrentAtPos

Reported by: richelle Owned by:
Priority: minor Milestone: none
Component: ui.datepicker Version: 1.8.5
Keywords: Cc:
Blocked by: Blocking:

Using an inline datepicker which displays several months and specifying showCurrentAtPos is not working correctly.

When you click on a date (doesn't matter which month) it moves all months back as many steps as you've specified for showCurrentAtPos.

Say, I have set numberOfMonths = 3 and showCurrentAtPos = 2, if I click any date the months displayed will move 2 months back (so if Aug, Sep, Oct are displayed, I click on any day, the months jump back so that now Jun, Jul, Aug are displayed). If showCurrentAtPos is set to 1, after clicking on a date, the calendars move back 1 month.

$('#dp').datepicker({numberOfMonths: 3, showCurrentAtPos: 2});

Attachments (0)
Change History (10)

Changed October 26, 2010 03:02PM UTC by sergik comment:1

Hi all. I've fixed this issue in my project.

       /* Action for selecting a new month/year. */
	_selectMonthYear: function(id, select, period) {
		var target = $(id);
		var inst = this._getInst(target[0]);
		inst._selectingMonthYear = false;
		inst['selected' + (period == 'M' ? 'Month' : 'Year')] =
		inst['draw' + (period == 'M' ? 'Month' : 'Year')] =
		/*Fix line */
                if (period == 'Y'){inst['drawMonth'] = parseInt(inst['drawMonth'],10) + this._get(inst, 'showCurrentAtPos'); }

Changed December 13, 2010 11:10AM UTC by lesc comment:2

The fix from sergik above didn't work for me, as the _selectMonthYear method isn't fired when a date is selected (only from the dropdowns as far as I could tell). It appears that the calculation for moving the month location worked out every time the date is selected as well as when it's first drawn.

I've managed to get it working on mine by a quick (and probably dirty) fix, that passes a variable through to the _updateDatePicker, then _generateHTML methods so that it doesn't do the calculation on the clicking.

I would try and get this sorted cleanly, tested and forked on gitHub, but I'm a bit pressed for time, and this works for now. Hope it helps someone.

On line 892 change



this._updateDatepicker(inst, true);

Then on line 660 change

_updateDatepicker: function(inst) {


_updateDatepicker: function(inst, isClicked) {

Then on line 663 change



inst.dpDiv.empty().append(this._generateHTML(inst, isClicked))

Then on line 1353 change

_generateHTML: function(inst) {


_generateHTML: function(inst, isClicked) {

Then finally on line 1369 change

var drawMonth = inst.drawMonth - showCurrentAtPos;


var drawMonth = isClicked ? inst.drawMonth : (inst.drawMonth - showCurrentAtPos);

Changed January 13, 2012 10:06PM UTC by amh-mw comment:3

Changed October 11, 2012 09:04PM UTC by scottgonzalez comment:4

milestone: TBD1.11.0

Changed October 18, 2012 07:39PM UTC by mikesherov comment:5

status: newopen

Changed October 19, 2012 04:26PM UTC by mikesherov comment:6

#6733 is a duplicate of this ticket.

Changed December 09, 2012 11:58PM UTC by tj.vantoll comment:7

summary: Inline datepicker and showCurrentAtPosDatepicker: Inline datepicker and showCurrentAtPos

Test case against master -

Changed April 25, 2014 12:09PM UTC by tj.vantoll comment:8

#9999 is a duplicate of this ticket.

Changed June 24, 2014 11:38PM UTC by scottgonzalez comment:9

milestone: 1.11.0none

Changed July 14, 2014 07:09PM UTC by scottgonzalez comment:10

You're basically saying that you want showCurrentAtPos to be an init-only option and it shouldn't be considered after the datepicker has been rendered the first time. Is that what you're looking for?

I feel like there would need to be a different way to handle this than using showCurrentAtPos.