I've seen many post about fullcalendar here but none did solve my problem. I'm trying to load events from an external php file (JSON feed). Events aren't rendered in the calendar.
So here is my javascript code:
<script>
$(document).ready(function() {
var calendar = $('#calendar').fullCalendar({
defaultView: 'agendaWeek',
allDaySlot: false,
minTime: 8,
maxTime: 17,
defaultEventMinutes: 30,
weekends: false,
selectable: true,
selectHelper: true,
select: function(start, end, allDay) {
if (confirm("Voulez-vous réserver cette période?")) {
$('#idMedecin').val('<?php echo $_SESSION["idMedecin"]; ?>');
$('#idPatient').val('<?php echo $patient->numero; ?>');
$('#eventS').val(start);
$('#eventE').val(end);
$('#calendarForm').submit();
}
},
events: {
url: 'calendrier-feed.php',
type: 'POST',
data: {
idMedecin: '<?php echo $_SESSION["idMedecin"]; ?>'
},
error: function() {
alert('there was an error while fetching events!');
}
}
});
});
</script>
<div id="calendar">
</div>
And this is what I have in my calendar-feed.php:
getAllEvents($doc); foreach($liste as $event) { $event_arr = array(); $event_arr['id'] = $event->id; $event_arr['title'] = $event->patient; $event_arr['start'] = $event->start; $event_arr['end'] = $event->end; array_push($return_arr, $event_arr); } echo json_encode($return_arr); ?>
The JSON output looks like this:
[{"id":"22","title":"ASDC 1234 5434","start":"Mon Jul 15 2013 08:00:00 GMT-0400 (Est (heure d\u2019\u00e9t\u00e9))","end":"Mon Jul 15 2013 08:30:00 GMT-0400 (Est (heure d\u2019\u00e9t\u00e9))"},{"id":"23","title":"ASDC 1234 5434","start":"Mon Jul 15 2013 09:00:00 GMT-0400 (Est (heure d\u2019\u00e9t\u00e9))","end":"Mon Jul 15 2013 09:30:00 GMT-0400 (Est (heure d\u2019\u00e9t\u00e9))"}]
I'm totally clueless. Please help.
Thanks
Found a fix. I had to add this to my calendar-feed.php:
$event_arr['allDay'] = false;
Even tho it's "optional" in fullCalendar API, I still had to include it.
I first thought the date was the issue but it made no sense because I'm capturing the date from the select event in a string and stuff it into a varchar in mysql.
Anyway, problem solved :)
I worked with this plugin as well, and the difference between us are the structure of the date:
[{"id":"190","allDay":false,"editable":true,"title":"Sam Shift","start":"2013-07-14 18:00:00","duration":"8","end":"2013-07-15 02:00:00","color":"#00f"}]
you can view the my date is much simpler than yours, try to fix it and check.
Problem is with date
Structure and "allDay":false
I have used like this
[{"id":"106","title":"106","start":"2013-07-17T11:00:00+02:00","end":"2013-07-18T14:00:00+02:00","allDay":false,"backgroundColor":"#FF0000"},{"id":"107","title":"107","start":"2013-07-19T10:45:00+02:00","end":"2013-07-20T14:15:00+02:00","allDay":false,"backgroundColor":"#FF0000"},{"id":"108","title":"108","start":"2013-07-22T10:45:00+02:00","end":"2013-07-22T14:15:00+02:00","allDay":false,"backgroundColor":"#FF0000"},{"id":"109","title":"109","start":"2013-07-22T10:45:00+02:00","end":"2013-07-22T14:15:00+02:00","allDay":false,"backgroundColor":"#D7DF01"}]