我使用drblue:fullcalendar。显示工作正常,但我无法让任何类型的事件工作。我尝试过不同的。在下面的代码片段中,我尝试了加载事件:
Template.Schedule.helpers({
calendarOptions: {
// Standard fullcalendar options
schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
slotDuration: '01:00:00',
minTime: '07:00:00',
maxTime: '22:00:00',
lang: 'en',
defaultView: 'agendaWeek',
contentHeight: 500,
firstDay: 1,
timeFormat: 'HH:mm',
timezone: 'UTC',
selectable: true,
// Function providing events reactive computation for fullcalendar plugin
events: function(start, end, timezone, callback){
var events = [];
Assignments.find().map(function(doc){
var startTimeHours = Number(doc.time.substr(0, 2));
var startTimeMinutes = Number(doc.time.substr(3, 2));
var startDateTime = new Date(doc.date);
startDateTime.setHours(startDateTime.getHours() + startTimeHours);
startDateTime.setMinutes(startDateTime.getMinutes() + startTimeMinutes);
var endDateTime = new Date(doc.date);
var effort = doc.state == 'finished' ? doc.realEffort : doc.effort;
endDateTime.setHours(startDateTime.getHours() + effort);
endDateTime.setMinutes(startDateTime.getMinutes());
var getColorForState = function(state)
{
switch(state)
{
case 'finished': return '#00bb00';
}
return '#1197C1';
};
var getBorderColorForState = function(state)
{
switch(state)
{
case 'finished': return '#009900';
}
return '#004781';
};
return{
id: doc.title,
start: startDateTime,
end: endDateTime,
title: doc.title,
backgroundColor: getColorForState(doc.state),
borderColor: getBorderColorForState(doc.state)
}
}).forEach(function(event){
events.push(event);
});
callback(events);
},
// Optional: id of the calendar
id: "calendar1",
// Optional: Additional classes to apply to the calendar
addedClasses: "col-md-12"
// Optional: Additional functions to apply after each reactive events computation
}
});
Template.Schedule.events({
loading: function(isLoading, view){
console.log('hi');
}
});
客户端或服务器上没有JS错误,也没有日志条目。我也尝试过dayClick,选择和点击事件,但我没有得到任何日志条目。如果我把alert
放进去,我也什么也得不到。
不知道为什么投了反对票,如果您需要更多信息或详细信息,请提供。
无论如何,我能够解决它。那里有一些"错误"的代码,我没有找到任何示例,但是当我将相应的事件添加到选项中时,它就可以工作,即:
Template.Schedule.helpers({
calendarOptions: {
// all the various options
eventClick: function(event, jsEvent, view){
alert(event.title + "rnrn" + event.description);
},