Refetch events when switching fullcalendar views


I'm using 3 views in my calendar: month, agendaWeek, and agendaDay. After I add an event, I call refetchEvents to display the new event. If I add an event from agendaWeek or agendaDay, the refetch will of course grab the events for the week or day. If I then switch to the month view, I only have the events for the week or the day.

I've tried adding a refetchEvents on viewDisplay. The problem with this is that it runs on the initial load which causes the duplication of all the events. Is there a way I can stop refetchEvents from being called during the calendar load?

Is there any other way to force the refetch when switching views?

share|improve this question
add comment (requires an account with 50 reputation)

Sounds like a good idea for an enhancment to fullcalendar library itself - the library could provide callback function for "viewChanged" or even "viewChanging" event. Such thing is really missing, because, if you need to create "AJAX deep linking", you also need to know when the view has changed.

Update: what happens if you change the "lazyFetching" optionhttp://arshaw.com/fullcalendar/docs/event_data/lazyFetching/ of your calendar after you add the event?

share|improve this answer
That did the trick! Thank you for your help. – Paul W Mar 10 '10 at 14:47
add comment (requires an account with 50 reputation)

When creating fullcalendar there is the viewDisplay method which is fired whenever the view is changed. Logically you can use this as a viewChanged event. For example:

$('#calendar').fullCalendar({
    ... 
    viewDisplay: function(view) { alert('viewDisplay(' + view + ')'); }
});



출처 - http://stackoverflow.com/questions/2417619/refetch-events-when-switching-fullcalendar-views



'Development > jQuery' 카테고리의 다른 글

jquery - .attr()와 .prop()  (0) 2013.10.25
jquery - fullCalendar events function  (1) 2013.07.29
jquery - 이벤트 다시 설정(로드)  (0) 2013.06.27
jQuery - History/Back Button plugins  (0) 2013.06.25
jquery - 메소드 정리  (0) 2012.11.01
Posted by linuxism
,