Closed cipriano200 closed 10 months ago
What about getOption('view') or getView() methods?
I tried this:
dayHeaderFormat: function(date) {
console.log( calendar.getview() );
}
But is not working: Uncaught TypeError: Cannot read properties of undefined (reading 'getview')
Indeed, the calendar
is not yet defined at the time of the first call to the function. But you can add an if
and you know which view is initially active:
let calendar;
calendar = new EventCalendar(document.getElementById('ec'), {
view: 'timeGridWeek',
dayHeaderFormat: function(date) {
if (!calendar || calendar.getView().type == 'timeGridWeek') {
// timeGridWeek
} else if (calendar.getView().type == 'timeGridDay') {
// timeGridDay
} else {
// and so on...
}
}
};
Works! Thank your for the help. I have replaced FullCalendar with your library.
dayHeaderFormat should have view variable as second parameter?