Meteor FullCalendar dayClick转换事件

时间:2015-11-15 23:29:31

标签: javascript meteor fullcalendar

我正在使用meteor和fullcalendar。我试图在我的模板中使用dayClick:function但它不起作用。

我想在没有使用jQuery的情况下单击当天点击日期。我理解模板.....事件的设置方式是不起作用的。我显然不了解一些(很多)事情。

模板:

JS

Template.calendar2.helpers({
calendarOptions: {
    // Standard fullcalendar options
    height: 700,
    hiddenDays: [],
    slotDuration: '01:00:00',
    minTime: '08:00:00',
    maxTime: '19:00:00',
    lang: 'en',
    // Function providing events reactive computation for fullcalendar plugin
    events: function(start, end, timezone, callback) {
        //console.log(date);
        //console.log(start);
        //console.log(end);
        //console.log(timezone);
        var events = [];
        // Get only events from one document of the Calendars collection
        // events is a field of the Calendars collection document
        var calendar = CalEvents.findOne(
            { "_id":"myCalendarId" },
            { "fields": { 'events': 1 } }
        );
        // events need to be an array of subDocuments:
        // each event field named as fullcalendar Event Object property is automatically used by fullcalendar
        if (calendar && calendar.events) {
            calendar.events.forEach(function (event) {
                eventDetails = {};
                for(key in event)
                    eventDetails[key] = event[key];
                events.push(eventDetails);
            });
        }
        callback(events);
    },
    // Optional: id of the calendar
    id: "calendar1",
    // Optional: Additional classes to apply to the calendar
    addedClasses: "col-md-8",
    // Optional: Additional functions to apply after each reactive events computation
    autoruns: [
        function () {
            console.log("user defined autorun function executed!");
        }
    ]
},
});

这是事件

Template.calendar2.events({
    dayClick:function( date, allDay, jsEvent, view ) {
            CalEvents.insert({title:'New Event',start:date,end:date});
            Session.set('lastMod',new Date());
    }
)};

1 个答案:

答案 0 :(得分:0)

我想我对日历的完整程度没有足够的了解。我不需要点击事件来启动日期/事件。 fullcalendar已经有办法用dayClick来做到这一点:function();我只需要在calendaroptions {};

dayClick: function(date, jsEvent, view) {
        CalEvents2.insert({title:'NEW', start:date._d, end:date._d});
        Session.set('clickedDate', tempEvent);
        IonModal.open('_cal2Modal');
    },