我正在尝试将事件推送到fullcalendar,但它似乎阻止了我的代码一起工作。
$(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'
});
});
我的问题是我做得对吗,还是我误解了文档中的内容?
答案 0 :(得分:0)
您的代码中存在一些错误(即事件:推送)。您必须使用活动as a function或eventsSource才能获得此信息。这个例子将一个事件推送到callendar并在回调中呈现它。希望它有所帮助。
$('#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);
}
});