So, as I said before, I’m not a js coder. Yet… I created a function (on the same script where the calendar is rendered and named it “calendarRefetch”).
The complete code is the following (the calendarStart function works correctly):
<script>
function calendarStart() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'interaction', 'dayGrid' ],
locale: 'es',
defaultDate: dmx.parse('hoy.datetime.formatDate("yyyy-MM-dd")'),
editable: false,
eventLimit: false, // allow "more" link when too many events
events: dmx.parse('getReservas.data.getReservas'),
eventTextColor: 'white',
selectable: true,
unselectAuto: true,
eventClick: function(info) {
info.jsEvent.preventDefault();
dmx.parse('ModalReserva.show();ModalReserva.dataReservas.select('+ info.event.id +')');
},
dateClick: function(info) {
dmx.parse('fechaReservar.setValue("'+ info.dateStr +'");ModalReservar.show()');
}
});
calendar.render();
}
**function calendarRefetch() {**
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
});
calendar.refetchEvents();
}
</script>
spoiler alert: IT DOESN’T WORK (lol).
So, every time the query changes (and the serverconnect reloads), it supposed to invoke the calendar.refetchEvents() -I’m using fullcalendar v4- and reload (no recreate) the calendar…
I’m having the same problem, and it creates as many calendars as times I update the query…