Reputation: 4520
I used to have
$('#calendar').fullCalendar({
//some properties...
events: "/Agenda/GetEvents/",
});
It worked fine and my event showed correctly. Now I want to update the events (refetch) on a combobox selection, so here's what I changed:
$('#calendar').fullCalendar({
//some properties...
events: function (start, end) {
$.ajax({
url: '/Agenda/GetEvents/',
dataType: 'json',
data: {
start: Math.round(start.getTime() / 1000),
end: Math.round(end.getTime() / 1000),
utilisateur: $("#Utilisateur option:selected").val()
}
});
$('#Calendar').fullCalendar('refetchEvents');
},
});
The url at /Agenda/GetEvents/ gets called correctly and returns one event, but it won't show on the calendar anymore. Am I doing something wrong?
Upvotes: 2
Views: 4843
Reputation: 4477
remove callback function just call this from success block
$('#calendar').fullCalendar('refetchEvents');
Upvotes: 0
Reputation: 1
After some hours reading the code, I found a unexpected configuration about allDay option. Each event must have allDay=false, like this:
evts.push({ title: "Teste", start: "2014/01/18 10:30", end: "2014/01/18 13:00", allDay: false });
callback(evts);
Upvotes: 0
Reputation: 4520
The solution was hard to find, but I found a workable way here
http://mikesmithdev.com/blog/jquery-full-calendar/
Upvotes: 1
Reputation: 5989
Check the documentation here to fetch events with single source.
Few changes are needed.
$('#calendar').fullCalendar({
events: function(start, end, callback) {
$.ajax({
url: 'myxmlfeed.php',
dataType: 'xml',
data: {
// our hypothetical feed requires UNIX timestamps
start: Math.round(start.getTime() / 1000),
end: Math.round(end.getTime() / 1000)
},
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);
}
});
}
});
Upvotes: 2