开发者

jquery FullCalendar - delete all events in a selection

I am using FullCalendar and I'm using the select: function to allow the user to select one or more days, and then enter a value, which I will later save to a database. I want to clear the existing e开发者_StackOverflow社区vents in the selection before adding a new one, but I can't access the event property from within select function to then call fullCalendar('removeEvent', );. Any ideas?

Thanks!


The FullCalendar plugin provides a method clientEvents which returns all events that are stored locally at the client (e.g. if the calendar retrieves the data from a json feed, you only get those events that already got downloaded). As you cannot select something that is not visible, all events in the selected area are definitely in this cache. See http://arshaw.com/fullcalendar/docs/event_data/clientEvents/ for more information.

This method accepts an optional parameter idOrFilter, used to apply a filter before returning the events. This can be a list of IDs or (more valuable to you) a function. This function gets an event object and returns true (meaning: include this event in the result set) or false (discard it).

var eventsToDelete = $('#calendar').fullCalendar('clientEvents', function(event) {
    // check if event.start >= selection.start && event.start < selection.end ... etc.
});

eventsToDelete is now an array that contains all the events you want to delete.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜