IrfanClemson
IrfanClemson

Reputation: 1779

FullCalendar 5.1: How to Change Resources and Events Dynmically

I have a Full Calendar 5.1 project whose document could be seen at: https://fullcalendar.io/docs . There is also some jquery and bootstrap in the mix. I have the Full Calendar initialized as:

var calendarEl = document.getElementById('dv_calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
     resources: { url: dataRegionAgents }, 
});

In code above, the initial read is a JSON file. Similarly, in the same code block of initialization, the Events are also loaded from a JSON file. So far so good. What I need to do is to change the resources and the events based on another set of JSON files. The file names are created upon a button click and there is no issue in loading the JSON file. But I can't any example which would work for me my version of the FC library. Here is an older code which generates error:

$('#dv_calendar').fullCalendar('option', 'resources', dataRegionAgents);
$("#dv_calendar").fullCalendar("refetchResources");

The error I get is that fullCalendar() is not a function, which makes sense because that code is old; I have that working in FC's version 3.9, which is not an option for me.

The examples at Stackoverflow and other sites also seem to point toward the older version of FC.

So how can I load the new JSON files and display them inside the Calendar's Resources and Events?

Thank you in advance!

Upvotes: 1

Views: 1331

Answers (2)

luetn
luetn

Reputation: 11

Is it not enough to just call calendar.refetchEvents();?

Upvotes: 0

IrfanClemson
IrfanClemson

Reputation: 1779

Never mind. Instead of resetting the resources per the old libary's way like:

$('#dv_calendar').fullCalendar('option', 'resources', dataRegionAgents);

I have just found a way to load for the new library:

calendar.setOption('resources', dataRegionAgents);
calendar.setOption('events', dataRegionRoutes);
calendar.refetchEvents();

HTH someone!

Upvotes: 4

Related Questions