I want to create a function to generate my events.
In the documentation of fullCalendar i’ve find something:
{
events: function(start, end, callback) {
// ...
},
color: 'yellow', // an option!
textColor: 'black' // an option!
}
{
events: function() {
// ...
for (var k=0; k<myarray.length; k++)
{
title: myarray[0][0],
start: myarray[0][1]
}
},
color: 'yellow', // an option!
textColor: 'black' // an option!
}
Who does it mean start, end and callback?
I want to start the function when i load the calendar…
I want to do something like the second example…
How can i do?
Thanks a lot
As is explained in the documentation, the
eventsproperty, specified as a function, will be called by fullCalendar whenever it needs new event data. It will pass in 2 dates which represent the start and end dates of the currently viewed slice of time on the calendar. The third param given is a call back which your custom function should call when it has produced data for the given time frame, and you pass the generated event data to it.When the calendar first loads, it needs data for whatever view it is currently displaying. For example, if it’s in month view for the current date,
startwill be the first day of the current month, andendwill be the last day of the current month. Your function should produce an event data array (formatted as specified in the documentation) for that range of time and pass it into the call back function which was given as param 3.If the calendar is currently in month view, and displaying October 2010, and the user clicks the right button telling the calendar to advance to the next month, your function would be called with a start param of 1 Nov 2010 and an end param of 30 Nov 2010. You would produce event data for that time period and pass it into the callback param.
Based on the example which you gave (which has extreme JS syntax issues), I’d say you do not wish to use
eventsas a function. Rather, your code should produce a properly formatted event data array before calling.fullCalendar()and pass that array as theeventsproperty instead. Example: