【问题标题】:Event is not showing in Full Calender using codeigniter?事件未在使用 codeigniter 的完整日历中显示?
【发布时间】:2015-08-25 06:57:17
【问题描述】:

我使用事件 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'
            }
        ],";
}

我的浏览器控制台显示响应,但事件未显示在日历中?

请帮帮我。

谢谢

【问题讨论】:

  • 如果我的回答对你有帮助,请标记为回答。
  • 研究在你的inspections_record()函数中使用Codeigniter echo json_encode(你的事件的数组对象)

标签: javascript php jquery codeigniter fullcalendar


【解决方案1】:

我认为您应该删除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。这将导致日历不显示您的活动。

【讨论】:

    猜你喜欢
    • 2020-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多