I am enabling some dates as per the Ajax response form the server. Here is the code for the same :
$(function() {
$(document).on('change', '#booking_package_type', function() {
var bol = $.inArray($(this).val(), ["weekend", "full_week", "midweek", ""]);
var pkg_type = $(this).val();
if (bol == -1) {
$("#booking_end_date").prop("disabled", false);
} else {
$("#booking_end_date").prop("disabled", true);
}
$.get("/admin/bookings/fetch_dates", {
package_type: pkg_type
})
.done(function(data) {
$("#booking_start_date").datepicker("destroy");
$('#booking_start_date').datepicker({
beforeShowDay: function(date) {
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [data.dates.indexOf(string) != -1]
}
});
$("#booking_start_date").datepicker("refresh");
});
});
});
It is enabling the dates only that are sent from the server. Now, another thing I want is, when I'll select/click any enable dates inside the datepicker, I want next 3 dates from the one I selected manually also get selected automatically. How to do that ?
Any hints will be appreciated.