Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#6847 closed bug (duplicate)

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'
		});
	});
}

Change History (6)

comment:1 Changed 11 years ago by Scott González

Component: ui.coreui.datepicker

comment:2 Changed 11 years ago by chet

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).

Last edited 11 years ago by chet (previous) (diff)

comment:3 Changed 11 years ago by edelbrp

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.

comment:4 Changed 10 years ago by ruprict

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

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

comment:5 Changed 10 years ago by rdworth

Resolution: duplicate
Status: newclosed

comment:6 Changed 10 years ago by rdworth

Duplicate of #7322.

Note: See TracTickets for help on using tickets.