TulsaMJ
TulsaMJ

Reputation: 31

FullCalendar Cannot read property '_id' of null

I'm working with the latest version of FullCalendar (http://fullcalendar.io). FullCalendar displays a calendar plotting customer visit times. It stores calendar events internally to make it faster to go backward and forward to various months. It is working for the current month, the previous month, and on and on until I go back to February 2017, at which time I get the following error message in the JavaScript console:

Uncaught TypeError: Cannot read property '_id' of null
    at buildEventFromInput (fullcalendar.js:13527)
    at fullcalendar.js:12980
    at Object.success (fullcalendar.js:13110)
    at i (jquery-3.2.1.min.js:2)
    at Object.fireWith [as resolveWith] (jquery-3.2.1.min.js:2)
    at A (jquery-3.2.1.min.js:4)
    at XMLHttpRequest.<anonymous> (jquery-3.2.1.min.js:4)

The error appears to fire before the AJAX function that obtains the date information, but just to be sure I ran the query for that month, and the data looks fine. Once the error fires, if I go back to one of the months I've already viewed, I don't see the events anymore. The error message is apparently fouling that internal data storage somehow, although the JavaScript is still running or else I wouldn't be able to switch months anymore.

I'm hoping someone who is familiar with FullCalendar has seen this error before can point me in the right direction. The application is protected by a login and contains real client information, so constructing a mock-up for testing purposes will be pretty involved, so I'm hopig nnot to have to burn an hour or two doing that - but if no obvious answers present themselves I'll bite the bullet and do it.

THANKS for any help!

EDIT: Here's a test case.

http://scripturemenu.com/test/index.html

The error message is slightly different from what I reported above (it's trying to read property "hasTime" instead of property "_id" of undefined) - that happened when I switched out the real client names with the words "CLIENT NAME" and an ID, but it still occurs when you hit February.

Interestingly, when I was working with the code to get this test case working, the AJAX call was triggered on January as well, even though after I passed February no dates display on the calendar.

Upvotes: 0

Views: 5700

Answers (2)

ADyson
ADyson

Reputation: 62074

There's one piece of invalid event data present. Most of the events look correct, with and ID, start and end times, e.g.:

{"id":43969,"start":"2017-02-07","title":"CLIENT NAME 43969"}

But there's one which does not have any of these properties:

{"title":"CLIENT NAME "}

Consequently, fullCalendar does not know how to add it to the calendar, and therefore crashes.

This data was retrieved when changing the month view to February, which triggered an AJAX request to

http://scripturemenu.com/test/calendar-events-json.html?TechID=all&show=customer&start=2017-01-29&end=2017-03-05&_=1502777909174

You need to correct your source data, and/or the code which translates the source data into fullCalendar's JSON format.

Upvotes: 0

jperelli
jperelli

Reputation: 7207

There is an object without id in your february data. You can see it here: http://scripturemenu.com/test/calendar-events-json.html?TechID=all&show=customer&start=2017-01-29&end=2017-03-05&_=1502766053928

enter image description here

That could be the cause of your js error

Upvotes: 1

Related Questions