im feeding the calendar with the following function:
$('#calendar').fullCalendar( {
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay' },
editable: true,
eventLimit: true,
events: function(callback) {
$.ajax({
url: '/appointments.json',
dataType: 'json',
success: function(doc) {
var events = [];
$(doc).find('event').each(function() {
events.push({
title: $(this).attr('title'),
start: $(this).attr('start') // will be parsed
});
});
callback(events);
}
});
But i keep getting this error:
object is not a function //callback(events) line
On the js console of the browser. Any idea what the problem might be?
im feeding the calendar with the following function:
$('#calendar').fullCalendar( {
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay' },
editable: true,
eventLimit: true,
events: function(callback) {
$.ajax({
url: '/appointments.json',
dataType: 'json',
success: function(doc) {
var events = [];
$(doc).find('event').each(function() {
events.push({
title: $(this).attr('title'),
start: $(this).attr('start') // will be parsed
});
});
callback(events);
}
});
But i keep getting this error:
object is not a function //callback(events) line
On the js console of the browser. Any idea what the problem might be?
Share Improve this question edited Oct 14, 2014 at 13:16 ntonnelier asked Oct 14, 2014 at 13:09 ntonnelierntonnelier 1,5494 gold badges24 silver badges51 bronze badges 1- events: '/appointments.json' works just fine. The problem is in the function – ntonnelier Commented Oct 14, 2014 at 13:17
1 Answer
Reset to default 4Assuming you are using FullCalendar 2.*, as stated in the documentation, the signature for events
is
function( start, end, timezone, callback ) { }
The parameter with the name callback
is, in fact, start
which is a momentjs
object. To resolve your issue you must add the parameters to your function, so your code would be:
events: function( start, end, timezone, callback ) {
This will work as long as your events
(passed to the callback
) have the correct format and parameters defined in the documentation.
Edit:
If you want to set background color of each event according to a value on its json attributes, you should use eventRender
.
Check this jsfiddle where the background of each event is set when the event is rendering.
As is demonstrated in the jsfiddle, you can change the background, conditionally, based on a value provided by the json.