1

I have a FullCalendar in my Ruby On Rails application that works great.

Here is the initialisation code (HAML in Rails):

// Load fullcalendar
:javascript
  $(document).on('turbolinks:load', function (fullcalendar) {
    // page is now ready, initialize the calendar...
    $('#calendar').fullCalendar({
      events: '/dashboard.json',
      header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
              }
    });
  });

However, Turbolinks interferes with it somehow so that if I navigate to some other pages then back most of the time it will work but sometimes (especially after submitting a form on another page) it will fail to load the Calendar and give the following error:

TypeError: $('#calendar').fullCalendar is not a function. (In '$('#calendar').fullCalendar', '$('#calendar').fullCalendar' is undefined)

I'm absolutely baffled. On initial page load the function works fine, but only after navigating back to it (sometimes) with Turbolinks it suddenly decides the function has an error or isn't good enough somehow.

Thoughts?

Jeremy E
  • 463
  • 1
  • 7
  • 19

1 Answers1

0

The issue is not with the calendar, but in general with rendering javascirpt in your rails app. The answer is here

Yshmarov
  • 3,450
  • 1
  • 22
  • 41