To refresh the specific resource and its events I am trying the following steps:
Sample code
var resourceA = calendar.getResourceById('2');
resourceA.remove(); // Remove resource 2
var res =
{
id: 2,
title: 'Resource 2'
};
calendar.addResource(res); // To Add resource again
//Event creation
var evnt = [
{
resourceId : 2,
start : "2021-09-22 00:30:00",
end : "2021-09-22 01:30:00",
title : "Event 1"
},
{
resourceId : 2,
start : "2021-09-22 02:30:00",
end : "2021-09-22 03:30:00",
title : "Event 2"
}
];
calendar.addEventSource(evnt); //Create events of resource 2
Now what happens is: when I create resource 2 again, previous events are not being removed. So then when I add events, duplicate events are showing.
Is there any way I can remove all events of resource 2 when I remove resource and fetch the events again? To be clear: not all the events of the calendar, just the ones from resource 2. Or if there is any better way please suggest.
Thanks.