Change Fullcalendar event source after render

后端 未结 4 1460
心在旅途
心在旅途 2020-11-30 07:08

I\'ve been using FullCalendar v1.5.3 for a MS SharePoint replacement.

I\'m trying to re-render the calendar event\'s source. For instance, when the page loads by def

4条回答
  •  野性不改
    2020-11-30 07:41

    This is an old question but I was having a similar problem and RET's answer really helped, based on that I patched it with a counter that reset to make sure it wouldn't add duplicate event sources

        count = 0;
    fcSources = [wholePlan, allActivities];
    
    //calendar initialization {
    viewRender: function(view) {
    
            if (view.name == 'agendaWeek' || view.name == 'month') {
                $('#fullcal').fullCalendar('removeEventSource', fcSources.allActivities);
    
                if (count > 0) {
                    $('#fullcal').fullCalendar('addEventSource', fcSources.wholePlan);
                }
    
                count = 0;
            }
    
            if (view.name == 'agendaDay' && count == 0) {
                $('#fullcal').fullCalendar( 'addEventSource', fcSources.allActivities );
                $('#fullcal').fullCalendar('removeEventSource', fcSources.wholePlan);
    
                count += 1;
       }
    }
    

提交回复
热议问题