Reputation: 7122
I see from the documentation that fullCalendar is expecting event properties like 'title', 'start', and 'end' from the JSON feed.
My feed uses different property names('name', 'evtStart', 'evtEnd').
Is there a way to specifiy these custom names so that fullCalendar knows what they are?
So I added this code to specify the name of the parameters in the JSON feed:
var calendar = $('#calendar').fullCalendar({
startParam: 'startDateTime',
endParam: 'endDateTime',
events: {
url: '../api/events/2014-01-01/2015-01-01',
}
Thanks!
Upvotes: 0
Views: 446
Reputation: 14980
As sugested by @Mooseman and @MikeSmithDev you could use startParam
and endParam
for the start and end params.
For the title, since there is no option to change the parameter description, you can use eventRender
.
Consider the following JSON object:
{
id: "387",
name: "Learning PHP",
startDateTime: "2014-09-03 13:00:00",
endDateTime: "2014-09-03 15:00:00"
}
The following javascript will render the event as you need:
$('#calendar').fullCalendar({
// set source and define start and end params
events: {
url: '../api/events/2014-01-01/2015-01-01',
startParam: 'startDateTime',
endParam: 'endDateTime',
},
eventRender: function(event, element) {
// after rendering, since we don't have event.title,
// set the event.name inside the div for the title
element.find('.fc-event-title').html(event.name);
}
});
Upvotes: 1