Is it possible to discover/extract the currently displayed events from the FullCalendar object, (ref: http://arshaw.com/fullcalendar)?
Ideally, I'd like a secondary display for events, alongside the calendar, which should show only the currently displayed events, (e.g. if the calendar is on "March 2012", I only want to see March 2012 events in the secondary list).
I'm guessing I'll nedd to construct some sort of filter, but was hoping I might be able to pull the details straight back off the calendar. I figure the plugin must already have established which are valid for display...
Any pointers to a function/property I've missed would be greatly appreciated.
with version 2.x you can filter all client events loaded so far by the current view's intervalStart & intervalEnd - I use a factory function getIdOrFilter to do so
App.getIdOrFilter = function () {
var view = $('#calendar').fullCalendar('getView');
var start = view.intervalStart;
var end = view.intervalEnd;
return function (e) {
// this is our event filter
if (e.start >= start && e.end <= end) {
// event e is within the view interval
return true;
}
// event e is not within the current displayed interval
return false;
};
}
...
var events = $('#calendar').fullCalendar('clientEvents', App.getIdOrFilter());
Yes this is surprisingly hard to do. I've been digging around in FullCalendar a lot recently as I've been hacking a load of extra functionality into it for my own purposes. It doesn't store the information internally in that form but you can get at it with a small hack:
Insert at line 4243 (in fullcalendar 1.5.2)
t.eventResize = eventResize
//add starts
t.getShownEvents = function () {
evs = [];
for (id in eventElementsByID)
evs = evs.concat(eventsByID[id]);
return evs;
}
//add ends
Then do this to get an array of event objects currently being displayed:
var evs = $('#calendar').fullCalendar('getView').getShownEvents();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With