Reputation: 49
I want to show a flat jQuery datepicker with three months and initially the current month in the middle. My code :
$('#threeMonths').datepicker({
numberOfMonths:[1,3],
showCurrentAtPos: 1
});
In this form it changes the months displayed whenever I click on any date, and always one month back, why is that and how could I fix it?
Update >
The solution that fits my needs is to increment drawMonth in the onSelect callback, as my editing of Berker's answer demonstrates.
Upvotes: 1
Views: 977
Reputation: 7345
javascript:
<script type="text/javascript" language="javascript">
$(document).ready(function ()
{
// Add date picker
$(".date").datepicker({
dateFormat: "dd/mm/yy",
numberOfMonths: 3,
showCurrentAtPos: 1,
showWeeks: true,
showStatus: true,
changeYear: true,
changeMonth: true,
highlightWeek: true,
showOtherMonths: true,
selectOtherMonths: true,
// hot fix (month back slide problem)
onSelect: function (dateText, inst) {
inst.drawMonth +=1;
}
});
});
</script>
html:
<div class="date">Select a date!</div>
Upvotes: 1