Closed michelefellinger closed 1 year ago
I think there are 2 options. One is to include defaultViewDate (with a date in the month to show) in the new options to set. And the other is to call setFocusedDate() after setOptions().
The former only works when no date is selected yet. If the month has to be shown no matter a date is already selected or not, you need to opt for the latter.
Thank you for your quick response.
I'm using Version 1.2.0 (datepicker-full.js) and there is no setFocusedDate()
Method, but setDate()
does the job when called before setOptions()
.
Thank you!
Hi there....
I use changeMonth to load data asynchronously from a server to highlight specific Dates in the datepicker (inline). When I call setOptions to mark these dates, the view always resets to the current month. Is there a way to prevent this?
Thank you!
Initial Options
const startDateOptions = {
calendarWeeks: true,
container: document.querySelector("body"),
format: "dd.mm.yyyy",
language: "de",
todayBtn: false,
minDate: start.toDate(),
date: start.toDate(),
maxView: 0,
prevArrow: "<i class=\"fas fa-chevron-left\"></i>",
nextArrow: "<i class=\"fas fa-chevron-right\"></i>",
};
Update Part
let availableDates = {datesHighlighted: []};
data.list.forEach(function (date, index){
availableDates.datesHighlighted.push((moment(date, "YYYYMMDD")).toDate());
});
that.options.tempValues.datepicker.setOptions(availableDates);