说我有一个每天重复的事件。现在,用户想要删除星期一的活动,但留下所有其余的活动。我怎样才能做到这一点?现在因为它们都具有相同的重复ID,所以它将删除所有事件。我只想删除一个事件。
是否有其他东西删除然后Id?就像我不能在事件中使用我自己的属性来删除它?
答案 0 :(得分:2)
是的,您可以使用自己的属性。但是,当事件加载时,您需要在服务器端生成它们。
例如(我将以数组为例)
{
events: [
{
title: 'Event1', //required
start: '2011-04-04', //required
myUniqueID: '000001' //your UniqueID thats embedded in the event!
className: 'id000001' //your UniqueID that appears as a class on DOM and get directly using jquery
},
{
title: 'Event2',
start: '2011-05-05'
myUniqueID: '000002' //your UniqueID thats embedded in the event!
myOtherUnqieID: 'allYearOnly',
yetAnotherUniqueID: 'userDelete:no',
myBooleanID: false, //not enclosed in '' !!
className: 'id000002' //your UniqueID that appears as a class on DOM and get directly using jquery
}
// etc...
],
color: 'yellow', // an option for the whole source
textColor: 'black' // an option for the whole source
}
http://arshaw.com/fullcalendar/docs/event_data/Event_Object/
了解非标准字段
答案 1 :(得分:1)
如果您将id属性设置为事件(而不是myUniqueId,这是一个自定义属性),那么您可以使用以下命令删除具有此ID的一个或多个事件:
.fullCalendar("removeEvents", "your_event_id_here")
答案 2 :(得分:0)
当你拥有所有你的id时,使用Izet的想法。
但是当你在你的活动中没有id时,就像这样(当你设置id时也可以这样做):
eventClick: function(event){
$('#myCalendar').fullCalendar('removeEvents',event._id);
}
我已经清楚了为什么会出现问题: How do I delete this event from FullCalendar?
答案 3 :(得分:0)
我为这个答案创建了一个完整的特定解决方案,这个解决方案非常简单。秘诀是使用自定义属性(在我的情况下为excludedDate),其中包括要从每日并发事件中排除的日期。 然后,在eventRender函数中,只有在到达此日期时才返回false。
eventRender: function(event, element, view) {
var theDate = event.start
var excludedDate = event.excludedDate;
var excludedTomorrrow = new Date(excludedDate);
//if the date is in between August 29th at 00:00 and August 30th at 00:00 DO NOT RENDER
if( theDate >= excludedDate && theDate < excludedTomorrrow.setDate(excludedTomorrrow.getDate() + 1) ) {
return false;
}
}