5

How do I add and then access additional values My_Custom_Value to the Event Object?

events: [
  {
    title: 'My Title',
    My_Custom_Value: 'some details',
    allDay: false,
    start: 1501056000000,
    end: 1501057800000
  }
],
ADyson
  • 57,178
  • 14
  • 51
  • 63

3 Answers3

7

Access your value through "extendedProps":

A plain object holding miscellaneous other properties specified during parsing. Receives properties in the explicitly given extendedProps hash as well as other non-standard properties."

https://fullcalendar.io/docs/event-object

eventRender: function(info){

                    console.log("_______ info _______\n");
                    console.log(info.event.extendedProps.My_Custom_Value);
}
3

Use extendedProps. You can include them in the event object directly (https://fullcalendar.io/docs/event-object), or add them afterwards using method Calendar::setExtendedProp (https://fullcalendar.io/docs/Event-setExtendedProp)

events: [
    {
        title: 'My Title',
        My_Custom_Value: 'some details',
        allDay: false,
        start: 1501056000000,
        end: 1501057800000
        extendedProps: {
            description: 'whatever',
            madeupProperty: 'banana'
        }
    }
]
2

The answer to this is contained in the Event Parsing documentation at https://fullcalendar.io/docs/event-parsing.

The way you're setting the custom property in your object is fine. As per that documentation, fullCalendar will read it, and then place it in the extendedProps property of the event object it creates internally.

So if you then need come to access that event later (e.g. via one of fullCalendar's callbacks such as eventClick, perhaps) you would use event.extendedProps.My_Custom_Value to access it.

ADyson
  • 57,178
  • 14
  • 51
  • 63