JavaScript executed before block is rendered

Created on 14 January 2019, over 6 years ago
Updated 5 June 2025, 3 days ago

Problem/Motivation

Steps to reproduce

  1. Install Drupal 8.6.4
  2. Install fullcalendar module. Make sure you have downloaded the library https://www.drupal.org/node/1056742 (library version ^3.3 I am using https://github.com/fullcalendar/fullcalendar/releases/tag/v3.9.0)
  3. Install big_pipe module
  4. Create a view with FullCalendar display. You can follow the Drupal 7 steps here https://www.drupal.org/node/1237808 , they are similar in Drupal 8
  5. Create a page display of the view, say path /calendar
  6. Create a block display of the view
  7. Place block in sidebar. Make sure that the block is not rendered in /calendar

Expected behavior
I should see the calendar in block.

Actual behavior
The calendar is not rendered.

Investigation

Relevant JS files which integrates fullcalendar library with DOM:

  1. fullcalendar.library.js
  2. fullcalendar.views.js
      // from fullcalendar.views.js
      for (var dom_id in settings.fullcalendar) {
        if (settings.fullcalendar.hasOwnProperty(dom_id)) {
          if (typeof Drupal.fullcalendar.cache[dom_id] === "undefined") {
            // This integrates the library with DOM
            Drupal.fullcalendar.cache[dom_id] = new Drupal.fullcalendar.fullcalendar(dom_id);
          }
        }
      }
  // from fullcalendar.library.js
  Drupal.fullcalendar.fullcalendar = function (dom_id) {
    // skipped for simplicity...
    this.$calendar.find('.fullcalendar').once().fullCalendar(this.$options);
    // skipped for simplicity...
  };

I found that the JS this.$calendar.find('.fullcalendar').once().fullCalendar(this.$options) is executed before the block DOM is loaded in the page. And due to this the library is unable to hook into the block, thus the calendar is not displayed.

The problem does not occur if I uninstall the big_pipe module.

More details:

webserver name and version: Apache 2.4
PHP version - PHP 7.2
Drupal version - 8.6.4

Proposed resolution

Remaining tasks

User interface changes

N/A

API changes

Data model changes

N/A

Release notes snippet

🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇮🇳India subhojit777

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States dcam

    I've volunteered to help clean up the FullCalendar issue queue. As part of that effort I'm closing issues open for unsupported versions of the module as "Closed (outdated)".

    #7 makes it sound like this was possibly caused by an issue in Drupal Core. If this issue is still relevant for version 3.x of FullCalendar, then feel free to re-open it and update the issue version number.

Production build 0.71.5 2024