Skip to main content

Search and Top Navigation

#7288 closed bug (worksforme)

Opened April 27, 2011 07:53AM UTC

Closed October 19, 2012 06:52PM UTC

Last modified November 23, 2015 08:24PM UTC

DatePicker jumps months when going to the Next/Previous month

Reported by: niko1312 Owned by:
Priority: minor Milestone: 1.11.0
Component: ui.datepicker Version: 1.8.11
Keywords: Cc:
Blocked by: Blocking:

OS: Windows 7 Professional, 64 bit

Browser: Google Chrome - 10.0.648.204

jQuery UI: 1.8.11

jQuery: 1.5.1

I use this code to enable the date picker for an Yearly calendar:


$(function() {

$( "#datepicker" ).datepicker({

firstDay: 1,

stepMonths: 12,

showCurrentAtPos: new Date().getMonth(),

numberOfMonths: [3, 4],

dateFormat: "mm-dd-yy"






<div class="demo">

Date: <div id="datepicker"></div>


After the page load the first month is Jan,2011.

When changing for the next year and/or previous year, the months are jumping - the first month is not January 2011, but e.g. April 2011, etc

Expected: After moving years forth and behind the months should stay as they were initially displayed.

Possible solution: I added this block of code to the 1399 line of thejquery.ui.datepicker.js file:

if (inst.drawMonth == showCurrentAtPos){

drawMonth = inst.drawMonth - showCurrentAtPos;



drawMonth = inst.drawMonth;


And no jumping was seen for my situation.

Attachments (0)
Change History (5)

Changed October 11, 2012 02:43PM UTC by scottgonzalez comment:1


Changed October 19, 2012 06:52PM UTC by mikesherov comment:2

resolution: → worksforme
status: newclosed

Thanks for taking the time to contribute to the jQuery UI project! I can no longer reproduce the issue using the latest jQuery and jQuery UI.

If you can still reproduce it, please feel free to reopen the bug. Thanks!

Changed February 12, 2014 06:07PM UTC by cfalletta comment:3


I've run into this jumping problem and struggled to find what was causing this jump since it seems to have been fixed.

It appears that i was updating the "minDate" in the "onSelect" method of my datepicker :

$(this).datepicker("option", "minDate", dateText);

-> this caused the unfortunate jump...

A solution i found was to comment this line in jquery-ui

_optionDatepicker: function(target, name, value) {


//this._setDate(inst, date);


I don't know what it does... But everything is working ok when i comment this line...

If i upgrade jquery later on, i wouldn't like my change to be overriden so i'll leave you guys handle this remaining bug and hope it will be fixed in the upcoming releases.

Changed February 12, 2014 06:31PM UTC by scottgonzalez comment:4

Please file a new ticket and provide a reduced test case that shows the problem.

Changed November 23, 2015 08:24PM UTC by syryos2 comment:5

I found a solution and patched the jquery-ui.js in basically two code lines in the datepicker subroutines _adjustDate() and _updateDatepicker() (see also cross-posting in ):

--- jquery-ui.orig.js	2015-11-23 20:04:52.000000000 +0100
+++ jquery-ui.js	2015-11-23 17:56:37.987111191 +0100
@@ -8815,6 +8815,8 @@
 				origyearshtml = inst.yearshtml = null;
 			}, 0);
+		// FIX BUG
+		inst.drawMonth += this._get(inst, "showCurrentAtPos");
 	// #6694 - don't focus the input if it's already focused
@@ -8940,9 +8942,14 @@
 		if (this._isDisabledDatepicker(target[0])) {
+		// FIX BUG
+		/*
 		this._adjustInstDate(inst, offset +
 			(period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
+		*/
+		this._adjustInstDate(inst, offset, period);