Search code examples
javascriptvue.jsfullcalendarfullcalendar-4

Click event on fullcalendar.js plugin not working


I am trying to display a calendar in VueJS. I need the following things :

  • Month view
  • Week view
  • Day view when I click on a cell
  • To display data in each cell of my calendar

I can't use Vuetify plugin because I am already using Bootstrap, that's why I am using fullcalendar.js plugin (https://fullcalendar.io/docs/vue).

However, it doesn't seem the API behind the component is working properly,

<template>
<div>
    <FullCalendar :plugins="calendarPlugins"
                  :weekends="false"
                  @dateClick="handleDateClick"
    />
</div>
</template>

<script>
    import FullCalendar from '@fullcalendar/vue'
    import dayGridPlugin from '@fullcalendar/daygrid'

    export default {
        name: "Calendar",

        components: {
            FullCalendar // make the <FullCalendar> tag available
        },

        data() {
            return {
                calendarPlugins: [ dayGridPlugin ]
            }
        },
        methods: {
            handleDateClick(arg) {
                alert(arg.date)
            }
        }
    }
</script>

<style lang='scss' scoped>
    @import '~@fullcalendar/core/main.css';
    @import '~@fullcalendar/daygrid/main.css';
</style>

When I click on a date no event if fired, and I don't have any error that appears in the console.. What I am doing wrong here ?

Thanks for your help !

enter image description here


Solution

  • According to the FullCalender documentation:

    In order for this callback to fire, you must load the interaction plugin.