Skip to main content

Search and Top Navigation

#6847 closed bug (duplicate)

Opened January 12, 2011 01:43PM UTC

Closed May 27, 2011 08:12PM UTC

Last modified May 27, 2011 08:12PM UTC

datepicker with 'numberOfMonths' and 'yearRange' defined only shows 2011 in january 2011

Reported by: duh Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.datepicker Version: 1.8.7
Keywords: Cc:
Blocked by: Blocking:
Description

When attaching a datapicker to an input element using the dateRange and numberOfMonths functionality, the only year shown is 2011. We are using:

jQuery: 1.4.4

jQuery-ui: 1.8.7 (custom, everything included)

FireFox: 3.6.13

OS: Mac OS X Snow Leopard 10.6.6

Actualy behaviour:

Only 2011 is shown in the year select

Expected behaviour:

Years 1931 - 2031 should be shown in the year select

Example code to reproduce:

// add datepickers to date fields
function attachDatePickers() {
	$("input[type=text][rel$='date']").each(function() {
		$(this).datepicker({
			changeMonth : true,
			changeYear  : true,
			numberOfMonths: 3,
			showButtonPanel: true,
			dateFormat  : 'dd/mm/yy',
			yearRange   : 'c-80:c+20',
			altField	: '#' + $(this).attr('name') + 'Example',
			altFormat   : 'DD, d MM, yy'
		});
	});
}

And the input element(s):

<input name="startdate" value="" rel="date" maxlength="10" size="10" id="startdate" type="text">

<input name="startdateExample" class="isExample" disabled="disabled" size="30" id="startdateExample" value="" type="text">

Workaround

The issue can be pinpointed to the 'numberOfMonths' property. When 'numberOfMonths: 3' is commented out, the year range is shown as expected (years 1931 - 2031 are shown in the year select element):

// add datepickers to date fields
function attachDatePickers() {
	$("input[type=text][rel$='date']").each(function() {
		$(this).datepicker({
			changeMonth : true,
			changeYear  : true,
			/*numberOfMonths: 3,*/
			showButtonPanel: true,
			dateFormat  : 'dd/mm/yy',
			yearRange   : 'c-80:c+20',
			altField	: '#' + $(this).attr('name') + 'Example',
			altFormat   : 'DD, d MM, yy'
		});
	});
}
Attachments (0)
Change History (6)

Changed January 12, 2011 01:50PM UTC by scottgonzalez comment:1

component: ui.coreui.datepicker

Changed February 25, 2011 04:33AM UTC by chet comment:2

_comment0: Has this bug been fixed yet?1298608509536399
_comment1: Has this bug been fixed yet? I'm having the same problem and I don't want to 'comment out' the numberOfMonths.1298608714206089
_comment2: Has this bug been fixed yet? I'm having the same problem and I don't want to 'comment out' the numberOfMonths. It has no problem with IE and Chrome, but only on Firefox (haven't tested safari yet).1298608846318235

Has this bug been fixed yet? I'm having the same problem and I don't want to 'comment out' the numberOfMonths and I also want the yearRange to work at the same time. It has no problem with IE and Chrome, but only on Firefox (haven't tested safari yet).

Changed March 24, 2011 11:48PM UTC by edelbrp comment:3

There's only one reference to Mozilla in the code for datepicker:

                        //when showing there is no need for later update
                        if( ! $.browser.mozilla ){
                                html += inst.yearshtml;
                                inst.yearshtml = null;
                        } else {
                                // will be replaced later with inst.yearshtml
                                html += '<select class="ui-datepicker-year"><option value="' + drawYear + '" selected="selected">' + drawYear + '</option></select>';
                        }

Please just simplify this to this to fix the problem:

                        html += inst.yearshtml;
                        inst.yearshtml = null;

BTW-Not sure that inst.yearshtml being set to null effects anything.. could be removed, but since it is applied to a majority of browsers I kept it in, in case it had some function I didn't know about.

Changed May 27, 2011 08:10PM UTC by ruprict comment:4

This is a dup of #7322, which went into 1.8.12.

http://bugs.jqueryui.com/ticket/7322

Changed May 27, 2011 08:12PM UTC by rdworth comment:5

resolution: → duplicate
status: newclosed

Changed May 27, 2011 08:12PM UTC by rdworth comment:6

Duplicate of #7322.