将额外字段添加到fullcalendar

时间:2010-08-27 15:03:38

标签: fullcalendar

我需要为我的日历创建更多字段(fullcalendar通过php连接到mysql)。我一直在阅读eventRender,但我不完全确定语法和我应该放在哪里。

目前我有以下内容;

$calendar.fullCalendar({
  timeslotsPerHour : 4,
  defaultView:'agendaWeek',
  allowCalEventOverlap : true,
  overlapEventsSeparate: true,
  firstDayOfWeek : 1,
  businessHours :{start: 8, end: 18, limitDisplay: true },
  daysToShow : 7,
        theme: true,
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },

        editable: true,
        events: "json-events.php",
  eventRender : function(calEvent, $event) {
       calEvent.distributor  //this is my new field

  },

但我没有工作,我找不到任何可用的例子来比较它。 感谢


感谢您的反馈,我已经能够使用eventRender添加自定义字段。所以现在不只是身体和描述被传递。

我现在的主要问题是将日期值传递给数据库,因为这些都没有保存。有没有人知道使用它的任何例子。我真的很感激它。

4 个答案:

答案 0 :(得分:8)

您可以在每个事件对象中包含您自己的非标准字段。 FullCalendar不会修改或删除这些字段。此示例可帮助您eventRender

并查看Event Object

答案 1 :(得分:6)

以下是我使用eventRender为每个事件添加一些类别的方法。然后我可以根据类别名称

过滤事件
eventRender: function(event, element) {
        element.attr("categories",event.categoryname)
    }

简直太棒了日历

答案 2 :(得分:3)

在Fullcalendar的第4版中,要获取非标准字段会有所更改。现在它只接受一个参数作为事件对象:

 events: [
{
  title: 'My Event',
  start: '2010-01-01',
  description: 'This is a cool event'
}
// more events here
],
eventRender: function(info) {
  console.log(info.event.extendedProps.description);
}

注意:您可以通过以下方式访问其他字段: info.event.extendedProps.description

Check documentation

答案 3 :(得分:-2)

这里有一些属性:

{
title: 'Birthday Party',
start: new Date(y, m, d + 1, 19, 0),
end: new Date(y, m, d + 1, 22, 30),
allDay: false,
backgroundColor: "#00a65a", //Success (green)
borderColor: "#00a65a" //Success (green)
},