我正试图将一个事件推送到完整日历中,但它似乎阻止了我的代码一起工作。
$(document).ready(function() {
// page is now ready, initialize the calendar...
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
editable: false, // Don't allow editing of events
handleWindowResize: true,
weekends: false, // Hide weekends
defaultView: 'agendaWeek', // Only show week view
header: false, // Hide buttons/titles
minTime: '08:00:00', // Start time for the calendar
maxTime: '22:00:00', // End time for the calendar
columnFormat: {
week: 'ddd' // Only show day of the week names
},
displayEventTime: true,// Display event time
events: [
{
title : 'event1',
start : '2015-11-18T08:30:00',
},
{
title : 'event2',
start : '2015-11-19T08:30:00',
end : '2015-11-19T09:30:00',
},
{
title : 'event3',
start : '2015-11-20T12:30:00',
allDay : false // will make the time show
}
]
events:push[
{
title: 'This is a Material Design event!',
start: '2015-11-20T11:30:00',
end: '2015-11-20T12:30:00',
color: '#C2185B'
}
];
});
events.push({
title: 'This is a Material Design event!',
start: 'someStartDate',
end: 'someEndDate',
color: '#C2185B'
});
});
我的问题是,我这样做是对的,还是误解了文档中的某些内容?
您的代码中存在一些错误(即events:push)。您必须将您的事件用作函数或事件源才能获得此信息。这个示例将一个事件推送到调用者,并在回调中呈现它。希望能有所帮助。
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
editable: false, // Don't allow editing of events
handleWindowResize: true,
weekends: false, // Hide weekends
defaultView: 'agendaWeek', // Only show week view
minTime: '08:00:00', // Start time for the calendar
maxTime: '22:00:00', // End time for the calendar
columnFormat: {
week: 'ddd' // Only show day of the week names
},
displayEventTime: true,// Display event time
events: function( start, end, timezone, callback ) {
var events =[
{
title : 'event1',
start : '2015-11-18T08:30:00',
},
{
title : 'event2',
start : '2015-11-19T08:30:00',
end : '2015-11-19T09:30:00',
},
{
title : 'event3',
start : '2015-11-20T12:30:00',
allDay : false // will make the time show
}];
events.push({
title: 'This is a Material Design event!',
start: '2015-11-20T08:30:00',
end: '2015-11-20T08:30:00',
color: '#C2185B'
});
callback(events);
}
});