meteor fullcalendar根本没有对事件做出反应

时间:2016-03-21 18:21:14

标签: events meteor fullcalendar

我使用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,select和clickEvent,但我没有得到任何日志条目。如果我把alert放入其中,我也没有收到任何东西。

1 个答案:

答案 0 :(得分:0)

不确定为什么downvoted,如果您需要更多信息或详细信息,请提供。

无论如何,我能够解决它。有一些"错误"代码在那里,我没有找到任何例子,当我只是将相应的事件添加到选项时,它可以工作,即:

Template.Schedule.helpers({
    calendarOptions: {
        // all the various options
        eventClick: function(event, jsEvent, view){
            alert(event.title + "\r\n\r\n" + event.description);
        },