簡體   English   中英

使用Codeigniter在“完全日歷”中未顯示事件嗎?

[英]Event is not showing in Full Calender using codeigniter?

我使用事件url從數據庫中檢索事件,但是在fullcalnder中不顯示事件?

我的Js代碼是

$('#inspectionCalendar').fullCalendar({

        header: {
            left: 'next today',
            center: 'title',
            right: 'month,basicWeek,basicDay'
        },
        editable: false,
        eventLimit: true, // allow "more" link when too many events
        events: '<?php echo base_url(); ?>inspections/inspections_record',
    }); 

我的控制器動作是:

 function inspections_record() {

    echo "[
            {
                title: 'All Day Event',
                start: '2015-08-01'
            },
            {
                title: 'Long Event',
                start: '2015-02-07'
            },
            {
                id: 999,
                title: 'Repeating Event',
                start: '2015-08-09T16:00:00'
            },
            {
                id: 999,
                title: 'Repeating Event',
                start: '2015-08-16T16:00:00'
            },
            {
                title: 'Conference',
                start: '2015-08-26'
            },
            {
                title: 'Meeting',
                start: '2015-08-25T10:30:00',
            },
            {
                title: 'Lunch',
                start: '2015-08-25T12:00:00'
            },
            {
                title: 'Meeting',
                start: '2015-08-25T14:30:00'
            },
            {
                title: 'Happy Hour',
                start: '2015-08-12T17:30:00'
            },
            {
                title: 'Dinner',
                start: '2015-08-12T20:00:00'
            },
            {
                title: 'Birthday Party',
                start: '2015-08-13T07:00:00'
            },
            {
                title: 'Click for Google',
                url: 'http://google.com/',
                start: '2015-08-28'
            }
        ],";
}

瀏覽器的控制台顯示響應,但日歷中未顯示事件?

請幫我。

謝謝

我認為您應該在要回顯的JSON末尾的[ ]之后刪除逗號。 您還必須用雙引號而不是單引號將json中的名稱和值起來。 這將使inspections_record()看起來像:

function inspections_record() {

    echo '[
            {
                "title": "All Day Event",
                "start": "2015-08-01"
            },
            {
                "title": "Long Event",
                "start": "2015-02-07"
            },
            {
                "id": 999,
                "title": "Repeating Event",
                "start": "2015-08-09T16:00:00"
            }
            etc...
        ]';
}

結論:您要提供給日歷的事件JSON無效JSON 這將導致日歷不顯示您的事件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM