如果我要序列化并在完整日历中使用它,我的数组应该如何显示?
(int) 1 => [
'start_date' => '2016-06-01',
'end_date' => '2016-06-01'
],
(int) 2 => [
'start_date' => '2016-06-02',
'end_date' => '2016-06-02'
],
(int) 3 => [
'start_date' => '2016-06-03',
'end_date' => '2016-06-03'
],
(int) 4 => [
'start_date' => '2016-06-04',
'end_date' => '2016-06-04'
],
(int) 5 => [
'start_date' => '2016-06-05',
'end_date' => '2016-06-05',
'events' => [
(int) 0 => [
'date' => 'E',
'name' => 'holliday'
],
(int) 4 => [
'date' => 'E',
'name' => 'holliday'
] ] ]
这是我的数组,我使用json_encode然后将其发送到我在事件中使用它的视图:但似乎这不起作用...
<script type="text/javascript">
$(document).ready(function() {
// Instantiate fullCalendar
// ================================
var date = new Date(),
d = date.getDate(),
m = date.getMonth(),
y = date.getFullYear();
var jData = $("#JSONdata").html();
$("#full_calendar").fullCalendar({
header: {
left: "prev,next",
center: "title",
right: "today,month,agendaWeek"
},
buttonText: {
prev: "<",
next: ">"
},
editable: true,
events:jQuery.parseJSON(jData),
eventClick: function (calEvent, jsEvent, view) {
// content
var pcontent = '';
pcontent += '<h5 class=semibold>';
pcontent += '<img class="mr10" src="/adminre1.2/image/icons/bloggingservices.png" width="42" height="42" />';
pcontent += calEvent.title;
pcontent += '</h5>';
pcontent += '<hr/>';
pcontent += '<p><span class="ico-clock"></span> Start: ';
pcontent += $.fullCalendar.moment(calEvent.start).format();
pcontent += '</p>';
if (calEvent.end !== null) {
pcontent += '<p><span class="ico-clock"></span> End: ';
pcontent += $.fullCalendar.moment(calEvent.end).format();
pcontent += '</p>';
}
// bootstrap popover
$(this).popover({
placement: 'auto',
container: 'body',
html: true,
trigger: 'manual',
content: pcontent
}).popover('toggle');
}
});
});
<div id='JSONdata' style="display:none;"><?php echo $results; ?></div>
这是我的javascript
答案 0 :(得分:0)
在官方文档中是您案例的示例: FullCalendar Events Array
Event对象具有start和end属性,而不是start_date和end_date。