Currently facing an issue with FullCalendar and Laravel where each time I navigate to the next/previous month, it triggers my ajax call for events. How can I prevent this behavior? My goal is to fetch events only once, and then merge them together when I select checkboxes for other calendars.
Check out the code snippet below:
$(".calendar_list").each(function () {
if (this.checked) {
selectedCalendars.push($(this).val());
}
});
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'dayGridMonth',
lazyFetching: true,
headerToolbar: {
left: 'prev,next today addEventButton',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
events: {
url: SITEURL + '/calendarsAjax',
method: 'GET',
extraParams: {
calendar_ids: selectedCalendars
},
success: function() {
},
failure: function (e) {
console.log(e);
}
},
});
calendar.render();
document.addEventListener('DOMContentLoaded', function() {
getCalendar();
});
I have attempted lazyloading but unfortunately the issue persists.