Grisza Grisza - 6 months ago 12
Javascript Question

Uncaught TypeError: Cannot read property 'fullCalendar' of undefined

Hi I'm using fullCalendar jQuery plugin. This code is written based on https://www.drupal.org/node/1345028#comment-5258592

I got issue:


Uncaught TypeError: Cannot read property 'fullCalendar' of undefined


What's wrong? Why this chaining doesn't work?

I wanted to make when user clicks on a day (dayClick), go to arbitrary date (gotoDate) and changes view (changeView)

$(document).ready(function(){
$('#calendar').fullCalendar({
header:
{
center: 'month,basicDay'
},
defaultView: 'month',
dayClick: function(date, allDay, jsEvent, view){
// here what's wrong ↓
$('#calendar').fullCalendar('gotoDate', date).fullCalendar('changeView', 'basicDay');



}
});
});

Answer

I belive your second call to fullCalendar in line below causes this

$('#calendar').fullCalendar('gotoDate', date).fullCalendar('changeView', 'basicDay');

Maybe try this or something similar:

$('#calendar').fullCalendar('gotoDate', date);
$('#calendar').fullCalendar('changeView', 'basicDay');
Comments