Any ideas how to set the month view on Event Calendar to set to a specific month i.e June?
2 Likes
Hi there, @user2343
Do I get it right that you’d like to skip months without events and show the month, where you have the closest event by default?
If this is the case, this code will help you achieve this:
let eventsInCalendar = 0;
const myInterval = setInterval(() => {
const calendar = document.getElementsByClassName('fc-daygrid-day');
let eventInTheCurrentMonth = false;
for(let i = 0; i < calendar.length; i++) {
let month = calendar[13].getAttribute('data-date').split('-')[1];
let currentEventMonth = calendar[i].getAttribute('data-date').split('-')[1];
eventInTheCurrentMonth = month == currentEventMonth;
if(calendar[i].innerHTML.includes('fc-event-start') == 1 && eventInTheCurrentMonth) {
eventsInCalendar++;
}
}
if (eventsInCalendar == 0) {
const buttonNext = document.querySelector('[class*="next-button"]');
buttonNext.click();
} else {
clearInterval(myInterval);
}
}, 300);
Please add it to the Custom JS field on the Settings tab of your widget’s settings and let me know if it helped
2 Likes