tonyhhisc
asked on
Jquery UI Datepicker w/Multidatepicker plugin, After Selecting a Date go back to same month as selection
I am using the Jquery UI Datepicker and it's working great except one last little fix needed.
The calendar pops up, and allows you to select multiple dates until you click "Done" or click outside of the datepicker popup.
What I want, is after the user clicks a date, say the calendar starts at January but the user selects a date in April. After selecting the date in april the calendar jumps back to show the month of January, where it started. I want it to show the month April so user can continue selecting in the month of April instead of having to click back to April each time they select another date.
I almost had it working by using this option in my jQuery.datepicker call:
onSelect: function(dateText, inst) { $( ".datepicker2" ).datepicker( "setDate" , dateText )
It works, by bringing the user back to the same month as just selected, However, it trumps the other dates that were previously selected, so then it only allows you to select one date instead of multiples.
It seems I just need something other than the "setDate" method but my excellent google searching skills have turned up nothing after many tries.
Thanks for any help you can give!!
My current Code looks like this:
The calendar pops up, and allows you to select multiple dates until you click "Done" or click outside of the datepicker popup.
What I want, is after the user clicks a date, say the calendar starts at January but the user selects a date in April. After selecting the date in april the calendar jumps back to show the month of January, where it started. I want it to show the month April so user can continue selecting in the month of April instead of having to click back to April each time they select another date.
I almost had it working by using this option in my jQuery.datepicker call:
onSelect: function(dateText, inst) { $( ".datepicker2" ).datepicker( "setDate" , dateText )
It works, by bringing the user back to the same month as just selected, However, it trumps the other dates that were previously selected, so then it only allows you to select one date instead of multiples.
It seems I just need something other than the "setDate" method but my excellent google searching skills have turned up nothing after many tries.
Thanks for any help you can give!!
My current Code looks like this:
<script>
$(function() {
var date = new Date();
$( ".datepicker").multiDatesPicker({
minDate: 0, showButtonPanel: true, changeMonth: true, changeYear: true, onSelect: function(dateText, inst) { $( ".datepicker" ).datepicker( "setDate" , dateText ) }
});
});
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This worked like a charm. Thank you so much!!
Glad to help. Good luck.
Set the defaultDate in the settings param when user selects a date.
See below for working example:
Open in new window