javascript - Removing all the eventSources in fullCalendar -
i have 2 types of events in fullcalendar. few fetched eventsources using :
$('calendar').fullcalendar('addeventsource' , 'source')
and few created user. using
$('calendar').fullcalendar('renderevent', eventdata, true)
now upon clicking button want remove events obtained eventsources , retain created user.
i tried doing :
$('calendar').fullcalendar('removeeventsource' , function(e){ return true ; } ) ;
but doesn't work. how achieve doing job ?
i did want in recent project. fullcalendar supports nonstandard fields.
non-standard fields
in addition fields above, may include own non-standard fields in each event object. fullcalendar not modify or delete these fields. example, developers include description field use in callbacks such eventrender.
so like
//save user created event $('#calendar').fullcalendar('renderevent', { title: title, end: end, start: start, editable : true, //nonstandard field isusercreated: true, description: description, });
then remove events hasn't been created user
//get client events var allevents = $('#calendar').fullcalendar('clientevents'); var usereventids= []; //find ever non usercreated event , push id array $.each(allevents,function(index, value){ if(value.isusercreated !== true){ usereventids.push(value._id); } }); //remove events ids of non usercreated events $('#calendar').fullcalendar( 'removeevents', usereventids);
or if need less control (as @a1rpun suggested)
$('#calendar').fullcalendar( 'removeevents', function(e){ return !e.isusercreated});
Comments
Post a Comment