There are many threads discussing a similar issue, but none that I could really understand and apply to my project.
I have a database with a table of events with a number of fields: "Field 1", "Field 2", "Field 3",... I have a PHP file (json.php) that json_encode's that table to JSON format, and I'm using the FullCalendar Plug in to get events from that file simply by:
events: "json.php"
Every event in the JSON format looks like this:
{
"Field 1": "value of Field 1",
"Field 2": "value of Field 2",
.
.
.
"Field n": "value of Field n",
"title": "the title"
"start": "some ISO8601 date string",
"end": "some ISO8601 date string"
}
The "title", "start" and "end" fields are the most important ones, as the FullCalendar events function by default needs these fields to create an event object and element.
This works fine. The events are rendered with the "title", "start" and "end" properties and show up in the calendar.
My question is how do I get FullCalendar to add the remaining fields as properties to the event object it creates?
I know the custom event function events(as a function) is my friend here, but I am quite new to this and even after reading all the relevant documentation, I'm still not clear as to how to achieve this, since I am not entirely certain of how the function works and my knowledge of AJAX is mediocre.
I'm sure the solution is very simple.
Thank you in advance
Solution:
FullCalender already does this automatically so there's no need for additional work here. The reason it didn't work for me was to do with something else in my code.
Thanks to ADyson!
FullCalendar Version 4: Any custom values will be found in 'extendedProps' of the Event Object
events: [
{
title: 'My Title',
My_Custom_Value: 'non-standard Event Object field',
allDay: false,
start: 1501056000000,
end: 1501057800000
}
],
eventRender: function(info){
console.log("_______ info _______\n");
console.log(info.event.extendedProps.My_Custom_Value);
}
"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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With