如何在“日历”页面中显示事件

时间:2014-11-20 06:15:12

标签: symfony fullcalendar

我在symfony2.5框架中工作。 在我的应用程序中,我有一个使用完整calendar.js jquery插件实现的日历页面。 (http://fullcalendar.io/)。 我有一个包含员工记录的事件表。事件

如何在日历页面中显示这些事件。

我的日历页面' s js:

$( '.calendar' ).fullCalendar({
        header: {
            left: 'prev,next,today',
            center: 'title,',
            right: 'month,agendaWeek,agendaDay'
        }
});

任何人都可以帮助我吗?在此先感谢!

1 个答案:

答案 0 :(得分:2)

首先,您需要在event documentation

之后将事件解析为fullCalendar事件对象
var myEvent = {id: 1, title: 'myTitle', start: moment(...)}

然后,您应该将这些事件添加到数组,函数,json ...

var mySourceEvents = [myEvent, myOtherEvent];

最后,您可以将fullcalendar配置中的数组设置为源。

$('#calendar').fullCalendar({
    eventSources: [
        mySourceEvents
    ]
});

或者......您可以将您的事件直接添加为数组:

$('#calendar').fullCalendar({
    events: [
        {
            title  : 'event1',
            start  : '2010-01-01'
        },
        {
            title  : 'event2',
            start  : '2010-01-05',
            end    : '2010-01-07'
        },
        {
            title  : 'event3',
            start  : '2010-01-09T12:30:00',
            allDay : false // will make the time show
        }
    ]
});