fullcalendar:日历不显示

时间:2017-08-22 10:43:24

标签: javascript jquery fullcalendar

日历未显示。我没有收到任何错误。请帮我解决这个问题。

HTML代码如下:

<div class="card-box">
   <div id='calendar' align="center" style="background-color: rgb(244, 247, 249); padding: 25px; margin: 0px;"></div>
</div>


$('#calendar').fullCalendar({
        defaultView: 'agendaDay',
        disableDragging: false,
        editable: false,
        selectable: true,
        eventLimit: true,
        nowIndicator: true,
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'agendaDay,agendaTwoDay,agendaWeek,month'
        },
        views: {
            agendaTwoDay: {
                type: 'agenda',
                duration: { days: 2 },
                groupByResource: true,
                groupByDateAndResource: true
            }
        },
        allDaySlot: false,
        resources: ConfRoomArrayDisplay,
        events: MeetingArrayDisplay,
        eventRender: function (event, element, view) {
            //code for render section
        },
        eventAfterRender: function (event, element, view) {
            $(element).removeClass("fc-short");
        }
    });

事件json格式如下:

MeetingArrayDisplay ="[{"id":"09CCDDE2-75FA-401A-B52D-23094809D3BF","resourceId":"1","start":"1970-01-01T00:00:00.006Z","end":"1970-01-01T00:00:00.006Z","title":"Weekly project review meeting","UserID":"6","Attendees":"","Repeated":"-","UserName":"tsa","url":"Javascript:"},{"id":"4E7E7C5A-04EA-4090-BCFB-5D3002233663","resourceId":"1","start":"1970-01-01T00:00:00.006Z","end":"1970-01-01T00:00:00.006Z","title":"project","UserID":"6","Attendees":"","Repeated":"-","UserName":"tsd","url":"Javascript:"}]"

日历渲染事件调用如下:

$('#calendar').fullCalendar('renderEvent', MeetingArrayDisplay);

enter image description here

1 个答案:

答案 0 :(得分:1)

您的事件数组中只有语法错误。从变量的开头和结尾删除引号("):

MeetingArrayDisplay ="[{"id":"09CCDDE2-75FA-401A-B52D-23094809D3BF","resourceId"‌​:"1","start":"1970-0‌​1-01T00:00:00.006Z",‌​"end":"1970-01-01T00‌​:00:00.006Z","title"‌​:"Weekly project review meeting","UserID":"6","Attendees":"","Repeated":"-","UserNam‌​e":"tsa","url":"Java‌​script:"},{"id":"4E7‌​E7C5A-04EA-4090-BCFB‌​-5D3002233663","reso‌​urceId":"1","start":‌​"1970-01-01T00:00:00‌​.006Z","end":"1970-0‌​1-01T00:00:00.006Z",‌​"title":"project","U‌​serID":"6","Attendee‌​s":"","Repeated":"-"‌​,"UserName":"tsd","u‌​rl":"Javascript:"}]";

变为

MeetingArrayDisplay =[{"id":"09CCDDE2-75FA-401A-B52D-23094809D3BF","resourceId"‌​:"1","start":"1970-0‌​1-01T00:00:00.006Z",‌​"end":"1970-01-01T00‌​:00:00.006Z","title"‌​:"Weekly project review meeting","UserID":"6","Attendees":"","Repeated":"-","UserNam‌​e":"tsa","url":"Java‌​script:"},{"id":"4E7‌​E7C5A-04EA-4090-BCFB‌​-5D3002233663","reso‌​urceId":"1","start":‌​"1970-01-01T00:00:00‌​.006Z","end":"1970-0‌​1-01T00:00:00.006Z",‌​"title":"project","U‌​serID":"6","Attendee‌​s":"","Repeated":"-"‌​,"UserName":"tsd","u‌​rl":"Javascript:"}];

现在它是一个有效的数组。在它无法解析之前。

有关工作示例,请参阅http://jsfiddle.net/sbxpv25p/6/