Is there any way to get FullCalendar to trigger a function when an Event is due or in progress?

Viewed 74

Is there any way to get FullCalendar to trigger a function when an Event is due or in progress? For example, I would like to pop up a notification that says an Event listed in FullCalendar is about to start.

1 Answers

You can always use the extendedProps to assign special properties:

var calendar = new Calendar(calendarEl, {
  events: [
    {
      title: 'BCH237',
      start: '2019-08-12T10:30:00',
      end: '2019-08-12T11:30:00',
      extendedProps: {
        'isAboutToStart': true //'2019-08-12T11:30:00' - Date.Now() > 
        'isDue': false // Date.Now() > '2019-08-12T11:30:00'
      },
      description: 'Lecture'
    }
    // more events ...
  ],
  eventDidMount: function(info) {
    console.log(info.event.extendedProps);
    // {description: "Lecture", isAboutToStart: "True", isDue: "False"}
  }    
});

And set this value according to the start or end property.

From Docs:

A plain object holding miscellaneous other properties specified during parsing. Receives properties in the explicitly given extendedProps hash as well as other non-standard properties.

Related