jQuery 所有星期天的 FullCalendar 活动
jQuery FullCalendar event for all Sunday
我需要为日历上的所有星期日添加一个活动。 FullCalendar 中有可用的选项吗?
day = 'Sunday'; <------ I need to pass this day to create event
var date = new Date();
var event = {id: result.id, title: from_time + '-' + to_time, start: new Date(date), allDay: false};
}
$('#calendar').fullCalendar('renderEvent', event, true);
请找一些事件重复的参考代码。
$('#calendar').fullCalendar( 'addEventSource',
function(start, end, callback) {
// When requested, dynamically generate virtual
// events for every sunday
var events = [];
for (loop = start.getTime();
loop <= end.getTime();
loop = loop + (24 * 60 * 60 * 1000)) {
var test_date = new Date(loop);
if (test_date.is().sunday()) {
// we're in Sunday, create the event
events.push({
title: 'I Love Sundays - Janty',
start: test_date
});
}
} // for loop
// return events generated
callback( events );
}
);
Repeat event every monday
您可以使用 dow
事件属性非常简单地完成此操作。它没有很好的记录,但在 backgroundEvents
and businessHours
中提到了它。它允许您设置事件将始终发生在星期几。
所以像这样:
$("#calendar").fullCalendar({
events:[{
title:"Monday",
dow:[1] //monday
//start/endtime works too
},{
title:"background",
dow:[2,3], //tuesday and wednesday
rendering: 'background'
}],
});
如果您需要更复杂的东西,例如仅在特定日期范围内重复事件,请在此处查看我的回答:
events: [
{
title:"Monday",
dow:[1] //monday
//start/endtime works too
},{
title:"background",
*daysOfWeek*: [2, 3], //tuesday and wednesday
rendering: 'background'
}]
我需要为日历上的所有星期日添加一个活动。 FullCalendar 中有可用的选项吗?
day = 'Sunday'; <------ I need to pass this day to create event
var date = new Date();
var event = {id: result.id, title: from_time + '-' + to_time, start: new Date(date), allDay: false};
}
$('#calendar').fullCalendar('renderEvent', event, true);
请找一些事件重复的参考代码。
$('#calendar').fullCalendar( 'addEventSource',
function(start, end, callback) {
// When requested, dynamically generate virtual
// events for every sunday
var events = [];
for (loop = start.getTime();
loop <= end.getTime();
loop = loop + (24 * 60 * 60 * 1000)) {
var test_date = new Date(loop);
if (test_date.is().sunday()) {
// we're in Sunday, create the event
events.push({
title: 'I Love Sundays - Janty',
start: test_date
});
}
} // for loop
// return events generated
callback( events );
}
);
Repeat event every monday
您可以使用 dow
事件属性非常简单地完成此操作。它没有很好的记录,但在 backgroundEvents
and businessHours
中提到了它。它允许您设置事件将始终发生在星期几。
所以像这样:
$("#calendar").fullCalendar({
events:[{
title:"Monday",
dow:[1] //monday
//start/endtime works too
},{
title:"background",
dow:[2,3], //tuesday and wednesday
rendering: 'background'
}],
});
如果您需要更复杂的东西,例如仅在特定日期范围内重复事件,请在此处查看我的回答:
events: [
{
title:"Monday",
dow:[1] //monday
//start/endtime works too
},{
title:"background",
*daysOfWeek*: [2, 3], //tuesday and wednesday
rendering: 'background'
}]