1

Having an issue with initializing V5.3.2 FullCalendar in Salesforce Lightning Web Component:

JS:

import { loadStyle, loadScript } from 'lightning/platformResourceLoader';

import fullCalendar from '@salesforce/resourceUrl/fullCalendar532';
// import fullCalendar from '@salesforce/resourceUrl/fullCalendar442';


export default class FullCalendarTestV5 extends LightningElement 
{
    async renderedCallback()
    {
        console.log(`## loading up calendar library...`);
        await Promise.all([
            loadScript(this, fullCalendar + '/lib/main.js'),
            loadStyle(this, fullCalendar + '/lib/main.css')

            // loadScript(this, fullCalendar + '/packages/core/main.js'),
            // loadStyle(this, fullCalendar + '/packages/core/main.css')
        ]).catch(error => {
            console.error(`## error: ${error}`);
        });

        console.log(`## loaded up calendar library...`);

        this.initialiseFullCalendarJs();

        

    }

    initialiseFullCalendarJs()
    {
        
        console.log(`## initializing calendar...`);

        const ele = this.template.querySelector("div.fullcalendarjs");

        console.log(`## ele: ${ele}`);

        let calendar = new FullCalendar.Calendar(ele, {});
        // calendar.render();
    }
}```

HMTL:

```<template>
    Full Calendar

    <lightning-card>
        <div id="calendar" class="fullcalendarjs slds-p-horizontal_small"></div>
    </lightning-card>
    
</template>

Error:

fullCalendarTestV5.js:4 Uncaught (in promise) ReferenceError: FullCalendar is not defined at s.initialiseFullCalendarJs (fullCalendarTestV5.js:4) at s.renderedCallback (fullCalendarTestV5.js:4)

Dima
  • 21
  • 1
  • 4
  • Have you check that the lib correctly loads as a first check ? Probably something like `FullCalendar !== undefined` ? Also if the lib try to manipulate the DOM, [it seems](https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.js_third_party_library) that you need to use `lwc:dom="manual"` directive. Do you have issues in your DevTool (in the browser) ? Do you see the lib being loaded in the Network tab ? – Bartheleway Feb 18 '21 at 10:34
  • It might be worth re-posting at: https://salesforce.stackexchange.com/ – Robs Aug 13 '21 at 20:43

0 Answers0