Is it possible to add a option "datesEnabled"?
Any dates apart from this option is disabled.
I want my users to know which dates they have made orders so they can select a date to view their orders on that date.
Thank you very much.
You can use the beforeShowDaycallback to achieve this kind of behavior, check if the current date equals on of the enabled dates otherwise return false. See beforeShowDay docs
Thank you @acrobat, this resolved the issue for me, but I think it would be a good option to have. Any reason the option datesEnabled was not added? I could do a PR and add it in if time was the issue.
Here is a working example for anyone that stumble upon this issue.
$('.js-datepicker').datepicker({
beforeShowDay : function(date) {
var date1 = new Date(2017, 00, 01);
var date2 = new Date(2017, 00, 18);
var date3 = new Date(2017, 01, 14);
var date4 = new Date(2017, 02, 22);
var date5 = new Date(2017, 04, 12);
var date6 = new Date(2017, 11, 25);
var dateArray = [date1.getTime(), date2.getTime(), date3.getTime(), date4.getTime(), date5.getTime(), date6.getTime()];
if (dateArray.indexOf(date.getTime()) == -1) {
return {
enabled: false
};
}
}
});
I am using datesEnabled as option. Then, all dates are disabled except the ones listed inside this array.
Tou can check https://github.com/mserralta/bootstrap-datepicker/commit/209e65acbb612d7bc09b75803b2b98146f87e850
Most helpful comment
Here is a working example for anyone that stumble upon this issue.