我正在使用Fullcalendar.js来开发预约应用。用户将能够创建定期约会,在该约会中,他们将能够选择每周重复的一天。
但现在我面临一个问题。假设用户只需要删除今天的约会,并让其他定期约会继续。
问题
如何让用户从我的申请中的定期约会中删除单一约会?
CODE:
$('#calendar').fullCalendar({
defaultDate: moment(),
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultView: 'month',
events: [{
title:"My repeating event",
start: '10:00', // a start time (10am in this example)
end: '14:00', // an end time (6pm in this example)
dow: [ 1, 2 ] //repeat every monday and tuesday
},{
title:"My repeating123 event",
start: '10:00', // a start time (10am in this example)
end: '14:00', // an end time (6pm in this example)
}],
});
答案 0 :(得分:0)
你需要在fullcalendar.js主文件中做一些事情。
只需用以下
替换原始功能function expandEvent(abstractEvent, _rangeStart, _rangeEnd) {
var events = [];
var dowHash;
var dow;
var i;
var date;
var startTime, endTime;
var start, end;
var event;
_rangeStart = _rangeStart || rangeStart;
_rangeEnd = _rangeEnd || rangeEnd;
if (abstractEvent) {
if (abstractEvent._recurring) {
// make a boolean hash as to whether the event occurs on each day-of-week
if ((dow = abstractEvent.dow)) {
dowHash = {};
for (i = 0; i < dow.length; i++) {
dowHash[dow[i]] = true;
}
}
// iterate through every day in the current range
date = _rangeStart.clone().stripTime(); // holds the date of the current day
while (date.isBefore(_rangeEnd)) {
if ((!dowHash || dowHash[date.day()]) && moment(date).format('YYYY-MM-DD') != moment().format('YYYY-MM-DD')) { // if everyday, or this particular day-of-week // Add your condition for today here...
startTime = abstractEvent.start; // the stored start and end properties are times (Durations)
endTime = abstractEvent.end; // "
start = date.clone();
end = null;
if (startTime) {
start = start.time(startTime);
}
if (endTime) {
end = date.clone().time(endTime);
}
event = $.extend({}, abstractEvent); // make a copy of the original
assignDatesToEvent(
start, end,
!startTime && !endTime, // allDay?
event
);
events.push(event);
}
date.add(1, 'days');
}
}
else {
events.push(abstractEvent); // return the original event. will be a one-item array
}
}
return events;
}