Extensible javascript FullCalendar object.

Created on 30 May 2025, 9 days ago

Problem/Motivation

The FullCalendar javascript library does not, in my opinion, do a great job of allowing you to extend the functionality of the widget outside of the initial render. You must have a reference to the javascript variable to change it. So when a module like this handles creating that object, and ultimately rendering that object, and that's within a Drupal javascript enclosure, there's really not any way to make a change to the calendar drawn on the page.

For my use case, for example, I want to provide a function to the library's `eventDidMount` callback. I don't think I see a great way to do this currently.

Proposed resolution

I want to propose a few thoughts for this module could easily expose this calendar object so that other tools can extend what this module is already doing... these are a bit untested, but just wanted to get some feedback on the idea.

In both suggestions below, the thought is some code could be added right after the .render() call here.

We could raise a simple javascript event that can be subscribed to, and pass the object as a parameter.

const calendarEvent = new CustomEvent('fullCalendarRendered', calendar);
document.dispatchEvent(calendarEvent);

Or alternatively, set the calendar object as globally avaialble.

window.FullCalendars = window.FullCalendars || {};
window.FullCalendars[domId] = calendar;

Remaining tasks

Discuss options?

User interface changes

None

API changes

None

Data model changes

None

✨ Feature request
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dpagini

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @dpagini
  • πŸ‡¨πŸ‡¦Canada mandclu

    I appreciate the thoughts raised here, but I wonder if you've been following what's been communicated about FullCalendar v7? It sounds like a release candidate due this month, so ideally any deeper refactoring to accommodate what is proposed here would be compatible with that.

    In terms of possible solutions, potentially this module allow for a configuration option that would be the name of a callback function. If provided, this module's JS could add that to EventDidMount when defining the FullCalendar object. There would still be some scope considerations to work out (or at least, document).

  • πŸ‡ΊπŸ‡ΈUnited States dpagini

    No, I hadn't seen that... but what kind of effort would that mean on this module? Do you expect that to be a kind-of plug and play change? I would imagine we might be talking new major release for this module? So does that make this module/branch in like a feature freeze?

  • πŸ‡¨πŸ‡¦Canada mandclu

    Hopefully the changes in the new version wouldn't derail anything we would do here, but knowing a new major version is close, I think it's worth keeping an eye on it.

    We are currently planning to have a new major version of the dependent fullcalendar_io project that brings in the library. We haven't really tested the impact of the changes in the new version on this module yet, so I can't predict whether supporting the new version would introduce BC changes. Ideally we could support it in a feature release.

Production build 0.71.5 2024