williamtroup / Calendar.js

📅 A javascript drag & drop event calendar, that is fully responsive and compatible with all modern browsers.
https://calendar-js.com
MIT License
504 stars 38 forks source link

Unable to add a new event. #135

Closed shernandezp closed 1 year ago

shernandezp commented 1 year ago

Describe the bug The calendarJs object cannot be instantiated. I downloaded the latest version and created a simple html in a local folder adding only the reference of calendar.js and I got the error "Uncaught TypeError: Cannot read properties of undefined (reading 'addEvent')" when trying to add a new Event to the calendar.

To Reproduce Steps to reproduce the behavior:

  1. Create a new folder and download on it the dist folder.
  2. Create an html document with the following code:

` <!DOCTYPE html>

`

image
  1. Scroll down to '....'
  2. See error in the browser console.

Expected behavior calendarInstance not to be undefined and be able to add a new event.

Screenshots

image

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

williamtroup commented 1 year ago

Your HTML looks a little off. HEAD tags are not supposed to be in the body.

I've just written this for you to get something working:

<!DOCTYPE html>
<html>
    <head>
        <title>Calendar.js</title>
        <link rel="stylesheet" href="../../dist/calendar.js.css" />
        <script src="../../dist/calendar.js"></script>
    </head>

    <body>
        <div id="calendar"></div>
    </body>

    <script>
        var calendarInstance = new calendarJs( "calendar", { 
            exportEventsEnabled: true, 
        } );

        document.title += " v" + calendarInstance.getVersion();

        var event = {
            from: new Date(),
            to: new Date(),
            title: "New Event",
            description: "A description of the new event"
        };

        calendarInstance.addEvent( event );
    </script>
</html>

Let me know how you get on. As of now, this is something I cannot recreate.