Monday, 26 April 2021

how attach import javascript to window

I am trying to import the javascript plugin FullCalendar in a Laravel webpack with:

import { Calendar } from '@fullcalendar/core';
import dayGridPlugin from '@fullcalendar/daygrid';

Then I compile this to my app.js file. Then I try to run the calendar:

<script src="app.js">/script>
<script>
    
            let calendar = new Calendar(calendarEl, {
                plugins: [ dayGridPlugin, timeGridPlugin, listPlugin ],
                initialView: 'dayGridMonth',
                headerToolbar: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'dayGridMonth,timeGridWeek,listWeek'
                }
            });
</script>

But then I get an error: Uncaught ReferenceError: Calendar is not defined

When I try to attach the calendar on a window, it doesn't work:

// does NOT work
window.Calendar = Calendar;
window.dayGridPlugin = dayGridPlugin;

How can I make this working?



from how attach import javascript to window

No comments:

Post a Comment