I have this problem with the AngularJS Ui-Calendar:
Inside the select callback function from fullcalendar, I create the events by dragging and the event is after that added to my events array.
After the events are created I want to delete some of them and for that reason I prepended a button, delete, that is calling the remove function from Ui-CalendarCalendar. The function is below:
function eventRenderFn(event, element, view) {
element.find(".fc-content").prepend("<button class='closeon btn btn-danger pull-right'>Delete</button>");
element.find(".closeon").on('click', function() {
removeEventById(event);
});
}
The problem is that after I delete an event, that event is still displayed on the calendar even if the event was removed from the events array.
I have tried adding the following code in the remove function to rerender the events but that wasn't solving my problem either because it was rerendering just the first time an event was deleted. The code is below:
uiCalendarConfig.calendars.myCalendar.fullCalendar('removeEvents');
uiCalendarConfig.calendars.myCalendar.fullCalendar('addEventSource', $scope.events);
The calendar looks like bellow:
I have been trying to find a solution for that problem for 2 days now.
Thank you for your time.
EDIT:
My remove function is:
function removeEventById(event) {
angular.forEach($scope.events, function (value, key) {
if (event._id === value._id) {
$scope.remove(key);
}
});
}
Where $scope.remove(key) is :
$scope.remove = function(index) {
$scope.events.splice(index, 1);
};