我正在尝试在我的应用程序中使用 jquery 扩展作为事件日历。我先用core 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 }
但这显示了树枝文件的代码。