"Fullcalendar's dateclick and eventclick events seem to be unresponsive and are failing

I recently set up fullcalendar in vuejs but encountered an issue with handling fullcalendar events. Whenever I attempt to trigger the dateClick and eventClick events, I receive the following warning in the console:

Event "dateclick" is emitted in component but the handler is registered for "dateClick". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "date-click" instead of "dateClick".

I have also attempted switching to date-click without success.

Here's my HTML:

    <script src="~/Scripts/vue/vue.js"></script>
    <link href='https://unpkg.com/@fullcalendar/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="680b071a0d285c46594658">[email protected]</a>/main.css' rel='stylesheet' />
    <link href='https://unpkg.com/@fullcalendar/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6307021a04110a0723574d524d53">[email protected]</a>/main.css' rel='stylesheet' />
    <link href='https://unpkg.com/@fullcalendar/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ffbe6e2eae8fde6ebcfbba1bea1bf">[email protected]</a>/main.css' rel='stylesheet' />
    <script src='https://unpkg.com/@fullcalendar/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f4979b8691b4c0dac5dac4">[email protected]</a>/main.js'></script>
    <script src='https://unpkg.com/@fullcalendar/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="acc8cdd5cbdec5c8ec98829d829c">[email protected]</a>/main.js'></script>
    <script src='https://unpkg.com/@fullcalendar/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="03776a6e6664716a6743372d322d33">[email protected]</a>/main.js'></script>
    <script src='https://unpkg.com/@fullcalendar/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d3babda7b6a1b2b0a7babcbd93e7fde2fde3">[email protected]</a>/main.js'></script>
    <script src="https://unpkg.com/@fullcalendar/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3046455570041e011e00">[email protected]</a>/main.umd.js"></script>

    <div id="app-el">
                    <full-calendar class="app-calendar"
                           default-view="dayGridMonth"
                           ref="fullCalendar"
                           :header="{
                                    left: 'prev,next today',
                                    center: 'title',
                                    right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
                                }"
                           :plugins="plugins"
                           :weekends="true"
                           :events="events"
                             
                           @@eventClick="eventClick"
                           @@dateClick="handleDateClick" />
    </div>

My JavaScript file:

var fullcalendar = Vue.component('FullCalendar', window['FullCalendarVue'].default);

document.addEventListener('DOMContentLoaded', function () {

    new Vue({
        el: '#app-el',
        components: {
            fullcalendar: fullcalendar
        },
        data: function () {
            return {
                showModal: false,
                plugins: [
                    window.FullCalendarDayGrid.default,
                    window.FullCalendarTimeGrid.default,
                    window.FullCalendarInteraction.default,
                ],

                events: [
                ]
            }
        },
       

        methods: {
            eventClick(args) {
               // this.$emit("event-click", this);
                this.showModal = true;
            },
            handleDateClick(arg) {
              console.log('handleDateClick');
            }
        }

    });

});

Answer №1

If you're encountering issues with

@@dateClick="handleDateClick"
, try using
@@date-click="handleDateClick"
instead. If that doesn't resolve the issue, refer to the discussion on the Github issue.

You can experiment with this potential solution:

<full-calendar ... @date-click="handleDateClick" />
 ...
 mounted() {
    const camelize = str => str.split('-').map((item, index) => index ? item.charAt(0).toUpperCase() + item.slice(1).toLowerCase() : item).join("")
    Object.keys(this.$refs.fullCalendar._events).forEach(name=>this.$refs.fullCalendar._events[camelize(name)] = this.$refs.fullCalendar._events[name])
}
...

For more information, check out: Prop Casing (camelCase vs kebab-case)

Answer №2

Utilizing vue.js from a local CDN resource requires adherence to HTML conventions. Event listeners should not be in camel-case, but rather separated by hyphens. For example:

@@date-click="handleDateClick"
should be used instead of
@@dateClick="handleDateClick"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Discovering the process of previewing a video upload using react-player

Currently, I have an input that allows users to upload video files of type File. In my application, there is also a react-player component that requires a URL prop, which can be either an array or MediaStream according to its documentation. After doing som ...

Tips on pausing a moving image from left to right and restarting it later

Is there a way to pause the left to right moving image at the end and then restart the loop? I tried utilizing this website link for assistance: https://www.w3schools.com/cssref/tryit.asp?filename=trycss3_animation-delay Unfortunately, I couldn't fi ...

I have a JavaScript code that smoothly scrolls to different id's on a webpage, but I need assistance in adding an exception for a particular id

I'm looking to incorporate smooth scrolling for all hash links in my JavaScript. However, I need the id=nav and its resulting hash link, /#nav, to be exempt from this functionality as it interferes with the menu responsiveness. Can someone provide gui ...

Customize the width of a DataTable cell in VuetifyJS

I am currently utilizing the VuetifyJS Data Table and I'm looking for a way to reduce the spacing between the entries in each header cell. Adding a width to each header did not achieve the desired result, as it seems there is a minimum predefined widt ...

Having difficulty sending emails with Nodemailer

This is a simple example showcasing the usage of Nodemailer library. var http = require('http'); var port = process.env.PORT || 8080; var async = require('async'); var nodemailer = require('nodemailer'); // Creating a transp ...

Generate JSON on-the-fly with ever-changing keys and values

I am new to coding and I'm attempting to generate JSON data from extracting information from HTML input fields. Can anyone guide me on how to create and access JSON data in the format shown below? { Brazilians**{ John**{ old: 18 } ...

Server time dictates the operation of Moment.js

I've been working with Moment.js and it's functioning correctly, but I can't seem to figure out how to make it run on server time instead of local time. I've tried a few things, but haven't had any luck. I'm unsure of how to ...

Guide to Implementing Vuetify within a Laravel 9 Vue SPA

My original intention was to integrate vuetify into my app. However, after installing the necessary packages and configuring resources\js\app.js, I encountered a runtime error: Uncaught TypeError: vue__WEBPACK_IMPORTED_MODULE_0___default.a is und ...

Overlaying images with cropped elements

When uploading an image on a webpage, I want to display a preview of the image. I am looking to create an overlay that showcases the image in a rectangle at the center, surrounded by a semi-transparent background outside the rectangle. Something resemblin ...

Having issues with Bootstrap affix functionality malfunctioning

I recently put together documentation using the CSS and JavaScript from Bootstrap docs. Here is a snippet of the sidebar code in my documentation: <div class="col-md-3 docs"> <div class="bs-docs-sidebar"> <ul class="nav docs-sid ...

What is the reason for the regeneration of the 2D array?

I have a method called generateWeights() that retrieves random values in an array; And a method named learn() that calls the changeWeights() method to alter the values in the array. Expected: Prior to invoking the learn() method, I anticipate receiving an ...

How to Save Styles as a CSS File in Angular 4

I'm a beginner in Angular 4 and I'm trying to export my styles as a css file. Whenever I serve or build the project, it generates a style.bundle.js file and includes the css as an html style element. However, I would like to export it as a style ...

Creating object properties dynamically based on specific conditions

Is there a more efficient way to create object properties that are dependent on certain conditions? For example, one can define a variable based on a condition like this: const foo = someCondition ? true : undefined However, what I am seeking is to achiev ...

NGINX/Express not serving static CSS and image files

I am facing an issue with my nginx server proxying my express application, which renders ejs files to html. When trying to load static css/image files, I am receiving a 404 error from nginx. Interestingly, this setup works fine locally where I do not have ...

What is the reason behind the absence of compile time errors when using 'string' functions on an 'any' field type variable in TypeScript?

Looking at the following typescript code snippet: let a; a = "number"; let t = a.endsWith('r'); console.log(t); It is worth noting that since variable 'a' is not declared with a specific type, the compiler infers it as ...

trouble seeing images with an array input and ngFor in Angular

I am encountering issues while attempting to exhibit an array of images by their source link using ngFor. It seems like there are errors hindering the functionality! Below is the image HTML code located within my card component: <div class="Session-Pa ...

Leverage the NextRouter functionality without the need for a React component

I've created a custom hook that checks if a user is logged in and redirects them to the login page if not. Below is a simplified version of the hook assuming the user is not logged in: import { useRouter } from 'next/router'; export default ...

Creating a Dynamic Input Validation Range with JQuery

Greetings and thank you for taking the time to review this! :-) The form validation is functioning correctly with required fields, but I am facing a challenge with setting up numeric range validation dynamically for an autocomplete feature. The JQuery val ...

Is it possible to load JavaScript code once the entire page has finished loading?

My webpage includes a script loading an external JavaScript file and initiating an Ajax query. However, the browser seems to be waiting for example.com during the initial page load, indicating that this external dependency may be causing a delay. Is there ...

Guide: Previewing uploaded images with HTML and jQuery, including file names

Any constructive criticism and alternative methods for accomplishing this task are welcomed. I am currently working on writing jQuery code that will allow users to preview file(s) without reloading the DOM. To achieve this, I have been using .append() to ...