私はsymfonyでフルカレンダーを使用しています。しかし、イベントはレンダリングされていません。私はいたるところで試しました。fullcalendarはイベントを表示しません
コントローラコード
/**
* @Route("/get-booking-to-calendar/{id}", name="booking-to-calendar")
*/
public function BookingCalendarAction($id)
{
$em=$this->getDoctrine()->getManager();
$field = $em->getRepository('AppBundle:Field')->find($id);
$bookings= $em->getRepository('AppBundle:Booking')->findBy(array('field_booking' => $field->getId()));
foreach($bookings as $booking)
{
$booking_array[] = array(
'id' => $booking->getId(),
'title' => $booking->getDuration(),
'start' => $booking->getStartTime(),
'end' => $booking->getEndTime(),
'allDay'=>true,
);
}
$response = new Response(json_encode($booking_array));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
小枝
<script>
$(document).ready(function() {
var calendar = $('#calendar').fullCalendar({
editable: true,
timeFormat: 'h:mm',
allDaySlot:false,
slotDuration : '00:15:00',
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
events: "{{ path ('booking-to-calendar', {'id':field_id}) }}",
// Convert the allDay from string to boolean
eventRender: function(event, element, view) {
if (event.allDay === 'true') {
event.allDay = true;
} else {
event.allDay = true;
}
},
});
});
</script>
と私のJSONの応答は、それが思わ
[{"id":2,"title":4,"start":{"date":"2016-06-18 11:00:00.000000","timezone_type":3,"timezone":"Europe\/London"},"end":{"date":"2016-06-18 12:00:00.000000","timezone_type":3,"timezone":"Europe\/London"},"allDay":true}]
ですeveythingは大丈夫です。イベントはカレンダーには表示されません。ここ
は、HTMLが
私のコントローラを変更します。それはどこで失敗しますか?私はそれのコードが表示されません。 –
eventRender関数は何に関係なく 'event.allDay'をtrueに設定します。それは意図的なのでしょうか? –
また、カレンダーdivのレンダリングされたhtmlを投稿できますか? –