Add more fields/data to a FullCalendar day

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 02:48:08

问题


I am working on a web app using the FullCalendar JQuery plugin to display the absence/presence of workers each day in a company.

I need to display several types (or fields) of information in each day. For example, I would like to display for each day: a Title (ex. "John is absent"), and Percentage(ex, "95% assistance"). And I would like this percentage to appear with a different format, on the bottom right corner of each day's box.

As far as I've seen, the possible fields to describe an event are basically these ones:

        events: [
        {
            title: 'John is sick',
            start: '2013-11-19',
            allDay: true
        },
        {
            title: 'Mike is on vacation',
            start: '2013-11-21',
            end: '2013-11-26',
            allDay: true
        }
    ]

Is there any way to add more fields (like the porcentage of assistance) to a FullCalendar day?

Edit: thanks to Henrique C's answer I managed to do it. Just to complete a little more the answer I would like to add that besides, doing what Henrique said in his answer, it is also necessary to do something like this:

$('#calendar').fullCalendar({
events: [
    {
        title: 'My Event',
        start: '2010-01-01',
        description: 'This is a cool event'
    }
    // more events here
],
eventRender: function(event, element) {
    element.qtip({
        content: event.description
    });
}

});


回答1:


Non-standard Fields This was taken from Fullcalendar website.

In addition to the fields above, you may also include your own non-standard fields in each Event Object. FullCalendar will not modify or delete these fields. For example, developers often include a description field for use in callbacks such as eventRender.

You can add any fields you want, fullcalendar will not change them.

events: [
    {
        title: 'John is sick',
        start: '2013-11-19',
        allDay: true,
        description: 'Hurrayyyyyyyyyy',
        myotherspecialfield: ':P'
    },
    {
        title: 'Mike is on vacation',
        start: '2013-11-21',
        end: '2013-11-26',
        allDay: true,
        description: 'Hurrayyyyyyyyyy'
        myotherspecialfield: ':P'
    }
]


来源:https://stackoverflow.com/questions/20070777/add-more-fields-data-to-a-fullcalendar-day

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!