Get view Info Fullcalendar V5

2.3k Views Asked by At

I am trying to get some information on the fullcalendar view. In particular I need to get 'activeStart' and 'activeEnd' every time the user change month. I'm currently using Fullcalendar V5 and I followed the guide at this link https://fullcalendar.io/docs/view-render-hooks

but I was unable to trigger an event when the user change month( Fullcalendar is rendered correctly). Using viewClassNames the event is triggered only if there are events in the month.

2

There are 2 best solutions below

4
On

I was able to find the event that generates the data I need. It is called from the events and return the displayed range date inside fullcalendar.

events: function( info, successCallback, failureCallback ) {
        console.log(info.startStr)
        console.log(info.endStr)
}

That return this json:

{start: Mon Sep 28 2020 00:00:00 GMT+0200, end: Mon Nov 09 2020 00:00:00 GMT+0100, startStr: "2020-09-28T00:00:00+02:00", endStr: "2020-11-09T00:00:00+01:00", timeZone: "local"}

0
On

ADyson is right that the correct way to achieve this specific behavior is to load events in the events callback. However, if anyone else stumples onto this question I figured that I could add how to actually get this information without the callback.

For FullCalendar v5 this is accessible through calendar.view.activeStart where calendar is your calendar object created with new Fullcalendar.Calendar().

For older versions it is accessible through: ('#calendar').fullCalendar('getView').start