I have installed the Fullcalendar library packages using npm.
npm i --save @fullcalendar/core
@fullcalendar/interaction @fullcalendar/daygrid
@fullcalendar/timegrid @fullcalendar/list @fullcalendar/bootstrap
I've also included it in the app.js.
require('@fullcalendar/core');
require('@fullcalendar/bootstrap');
require('@fullcalendar/list');
require('@fullcalendar/timegrid');
require('@fullcalendar/daygrid');
require('@fullcalendar/interaction');
However when trying to create a calendar with the following code:
var calendarEl = document.getElementById('calendar');
calendar = new Calendar(calendarEl, {
plugins: [ 'interactionPlugin', 'bootstrapPlugin', 'dayGridPlugin', 'timeGridPlugin', 'listPlugin'],
});
I get the error...
Uncaught ReferenceError: Calendar is not defined at HTMLDocument.<anonymous>
onnew Calendar
.
What am I doing wrong?
My webpack.mix.js looks like this:
const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css').version();
Edit:
After setting my app.js to:
window.FullCalendar = require('@fullcalendar/core');
window.bootstrapPlugin = require('@fullcalendar/bootstrap');
window.interactionPlugin = require('@fullcalendar/interaction');
window.listPlugin = require('@fullcalendar/list');
window.timeGridPlugin = require('@fullcalendar/timegrid');
window.dayGridPlugin = require('@fullcalendar/daygrid');
I now get this error:
Uncaught TypeError: Cannot read property 'length' of undefined
on
calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [bootstrapPlugin, interactionPlugin, listPlugin, timeGridPlugin, dayGridPlugin],
locale : 'pt-br',
})