#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 12 years ago by
Component: | ui.core → ui.datepicker |
---|
comment:3 Changed 12 years ago by
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:5 Changed 12 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
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).