0

I need your help.

I've implemented FullCalnedar Scheduler (free trial version) on my Salesforce sandbox as a Lightning Web Component but Scheduler cannot be initialized.

When I check the error on console with debug mode, it says "ReferenceError: Calendar is not defined at FullCalendarResourceTrial.initializationV5 (https://…}". I've already checked using console.log that variable ele is populated correctly by querySelector.

I'm very new to js and salesforce customization so there might be easy mistakes, but I appreciate if someone could help me solve this issue.

Thanks a lot!

JS

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

// Static resource of FullCalendar Scheduler v5.0.1
import SchedulerV501 from '@salesforce/resourceUrl/SchedulerV501';

export default class FullCalendarResourceTrial extends LightningElement {

    IsFullCalenderInitialized = false;

    renderedCallback(){
        if (this.IsFullCalenderInitialized) {
            return;
        }
        this.IsFullCalenderInitialized = true;
        this.loadScriptsByPromiseV5();    
    }

    loadScriptsByPromiseV5(){
        Promise.all([
            loadScript(this, SchedulerV501 + '/lib/main.js'),
            loadStyle(this, SchedulerV501 + '/lib/main.css')
        ])
        .then( () => {
            this.initializationV5();
        })
        .catch(error => {
            console.error({
                message: 'Error occured on FullCalendarScheduler',
                error
            });
        });
    }

    initializationV5(){
        let ele = this.template.querySelector('div.calendarmain');

        var calendar = new Calendar(ele, {
            initialView: 'resourceTimelineWeek',
        });
        calendar.render();
    }

HTML

<template>
    <div id='calendar' class="calendarmain"  lwc:dom="manual"></div>
</template>
ADyson
  • 57,178
  • 14
  • 51
  • 63
  • 1
    There is a Stack Exchange site specifically for Salesforce - you might have better luck there: https://salesforce.stackexchange.com – Tieson T. Jun 25 '20 at 07:30
  • Have you tried `var calendar = new FullCalendar.Calendar` instead? (I assume it's this line which throws the error? You didn't actually tell us.) – ADyson Jun 26 '20 at 10:30

0 Answers0