jQuery UI Datepicker Month & Year Menus Only Work Once -
i'm using jquery ui's month , year menus. here's what's happening , i'm running issue:
- click date field
- change month dropdown jan
- change year dropdown 2003
- click calendar day 1
- the date field correctly populated 01/01/2003
here's run issue:
- click date field (again)
- change month (or year) dropdown
- the date not change
- click off of datepicker hide it
- the date still not change
is there way use month or year dropdowns after date has been entered?
http://jsfiddle.net/ryanburnett/8n9xq/
<p>date: <input type="text" id="datepicker" /></p> $(function() { $( "#datepicker" ).datepicker({ changemonth: true, changeyear: true }); });
by design, month-year change doesn't refresh datepicker; can set new selected date (from dropdowns too) using onchangemonthyear
option:
called when datepicker moves new month and/or year. function receives selected year, month (1-12), , datepicker instance parameters. refers associated input field.
code:
$("#datepicker").datepicker({ changemonth: true, changeyear: true, onchangemonthyear: function (year, month, day) { $(this).datepicker('setdate', new date(year, month - 1, day.selectedday)); } });
working fiddle: http://jsfiddle.net/7xdhy/
Comments
Post a Comment