Javascript AngularJS UI日历-删除事件不会重新呈现事件
AngularJS Ui日历有以下问题: 在fullcalendar的selectcallback函数中,我通过拖动创建事件,然后将事件添加到我的事件数组中 创建事件后,我想删除其中的一些事件,因此我添加了一个按钮delete,该按钮调用Ui calendar中的remove函数。功能如下:Javascript AngularJS UI日历-删除事件不会重新呈现事件,javascript,angularjs,fullcalendar,ui-calendar,Javascript,Angularjs,Fullcalendar,Ui Calendar,AngularJS Ui日历有以下问题: 在fullcalendar的selectcallback函数中,我通过拖动创建事件,然后将事件添加到我的事件数组中 创建事件后,我想删除其中的一些事件,因此我添加了一个按钮delete,该按钮调用Ui calendar中的remove函数。功能如下: function eventRenderFn(event, element, view) { element.find(".fc-content").prepend("<button clas
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);
});
}
uiCalendarConfig.calendars.myCalendar.fullCalendar('removeEvents');
uiCalendarConfig.calendars.myCalendar.fullCalendar('addEventSource', $scope.events);
日历如下所示:
2天来,我一直在努力寻找解决这个问题的方法
谢谢你抽出时间
编辑:
我的删除功能是:
function removeEventById(event) {
angular.forEach($scope.events, function (value, key) {
if (event._id === value._id) {
$scope.remove(key);
}
});
}
其中$scope.removekey为:
removeEvent函数到底做什么?我们需要看到这一点。@ADyson我添加了remove函数。它似乎是从名为events的数组中删除事件,而不是从日历中删除事件。我看不出该数组是如何链接到日历的。即使最初将该数组作为事件参数指定给fullCalendar,fullCalendar也会在此时复制,但不会与之保持同步。我想你需要打电话。如果事件数据通常从服务器/数据库加载,您可能还需要更新服务器/数据库。@ADyson Ui calenar库有一个eventsWatcher,并且在触发$scope.remove时触发$scope.remove。onRemoved函数具有此内部日历。fullCalendar'removeEvents',event.\u id;我将removeEventById包装为超时,突然日历正常工作。我在evenDrawerfn函数中完成了$TimeOutRemoveEventByEvent。removeEvent函数的具体功能是什么?我们需要看到这一点。@ADyson我添加了remove函数。它似乎是从名为events的数组中删除事件,而不是从日历中删除事件。我看不出该数组是如何链接到日历的。即使最初将该数组作为事件参数指定给fullCalendar,fullCalendar也会在此时复制,但不会与之保持同步。我想你需要打电话。如果事件数据通常从服务器/数据库加载,您可能还需要更新服务器/数据库。@ADyson Ui calenar库有一个eventsWatcher,并且在触发$scope.remove时触发$scope.remove。onRemoved函数具有此内部日历。fullCalendar'removeEvents',event.\u id;我将removeEventById包装为超时,突然日历正常工作。我在evenDrawerfn函数中完成了$timeoutremoveventbydevent。
$scope.remove = function(index) {
$scope.events.splice(index, 1);
};