1
We have this example: http://jsfiddle.net/3eBLH/. When I click on the month of May, it renders the next 2 months.
There’s a way to disable it?
1
We have this example: http://jsfiddle.net/3eBLH/. When I click on the month of May, it renders the next 2 months.
There’s a way to disable it?
1
Your problem lies in the onSelect method, when you select the date you try to instantiate again, causing it to move on to the next months.
$(".date-picker").datepicker({
numberOfMonths: 3,
beforeShowDay: function(date) {
var date1 = $.datepicker.parseDate($.datepicker._defaults.dateFormat, $("#date-from").val());
var date2 = $.datepicker.parseDate($.datepicker._defaults.dateFormat, $("#date-to").val());
return [true, date1 && ((date.getTime() == date1.getTime()) || (date2 && date >= date1 && date <= date2)) ? "dp-highlight" : ""];
},
onSelect: function(dateText, inst) {
var date1 = $.datepicker.parseDate($.datepicker._defaults.dateFormat, $("#date-from").val());
var date2 = $.datepicker.parseDate($.datepicker._defaults.dateFormat, $("#date-to").val());
if (!date1 || date2) {
$("#date-from").val(dateText);
$("#date-to").val("");
// $(this).datepicker("option", "minDate", dateText);
} else {
$("#date-to").val(dateText);
// $(this).datepicker("option", "minDate", null);
}
}
});
The commented lines are your problem, what you are trying to do in them may be wrong.
The cool thing would be to do something like this: jsfiddle
0
This article helped me a lot:
Browser other questions tagged jquery jquery-ui datepicker
You are not signed in. Login or sign up in order to post.