I’m getting ready to use the JQuery-based FullCalendar in my online app using PHP/MySQL and noticed that when implementing recurring events, you must place a new item in the event array for each recurrence (using the same ID), like this:
events: [
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d-1, 16, 0),
allDay: false
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d+6, 16, 0),
allDay: false
},
{
id: 999,
title: 'Repeating Event',
start: new Date(y, m, d+13, 16, 0),
allDay: false
}
]
Okay, so that’s not a big deal. Using MySQL, I’ll just feed in the event looped a bunch of times, like maybe 100 in the future from the start date of that event if it doesn’t have an end date. But now I’m loading up the page with a bunch of JavaScript that might not even be needed (if the user just opens the calendar to see one month). Not cool.
There has to be a better way… does anyone have their own experience with this?
FullCalender will by default fetch events for the current time-frame using lazyFetching. Generally, this means you’ll only send-off an ajax call when the user switches out the current month. You can reduce server load by turning off caching:
Further, you should optimize your SQL on the server to only fetch events in a given timeframe:
If you use these get parameters in your SQL, you’ll drastically reduce the data you need to send to the client:
Obviously, this won’t be as succinct when using recurring events, you may for example (in pseudo-code):
This way, you’ll just send back to full calendar what is applicable for the current view.