アプリケーションでイベントカレンダーとしてjquery拡張機能を使用しようとしています。私は最初にコアphpでそれを試しました、そしてそれはうまくいきます。symfony2アプリケーションで使用したいのですが、twigファイルに表示できません。これが私がレンダリングに使用している私のコードですが、どこで間違っているのかわかりません。
コントローラ
public function studentCalendarAction()
{
$year = date('Y');
$month = date('m');
$response = new Response(json_encode(array(
array(
'id' => 111,
'title' => "Event1",
'start' => "$year-$month-10",
'url' => "http://yahoo.com/"
),
)));
$response->headers->set('Content-Type', 'application/json');
return $this->render('CollegeStudentBundle:StudentAttendance:calendar.html.twig',array('response'=>$response));
}
ルーター
CollegeStudentBundle_attendance_calendar:
pattern: /student/attendance/calendar
defaults: { _controller: CollegeStudentBundle:StudentAttendance:studentCalendar }
requirements:
_method: GET|POST
小枝
<script type='text/javascript'>
$(document).ready(function() {
$('#calendar').fullCalendar({
editable: true,
events: "../../student/attendance/calendar",
eventDrop: function(event, delta) {
alert(event.title + ' was moved ' + delta + ' days\n' +
'(should probably update your database)');
},
loading: function(bool) {
if (bool) $('#loading').show();
else $('#loading').hide();
}
});
});
</script>
</head>
<body>
<div id='calendar'></div>
</body>
Router
こんな風に作ろうとしても
CollegeStudentBundle_attendance_calendar:
pattern: /student/attendance/calendar
defaults: { _controller: CollegeStudentBundle:StudentAttendance:studentCalendar, _format: json }
requirements: { _format: (xml|json), _method: GET }
しかし、これは小枝ファイルのコードを表示します。