FullCalendar:使用 Google 日历事件的位置属性

FullCalendar: Use Location attribute of Google Calendar Event

我设置了 FullCalendar (v3.8.0) 从 Google 日历中提取事件数据,使用 qTip2 显示事件信息。这很好用。

我现在正在尝试显示事件的位置属性。可悲的是,我似乎无法弄清楚如何让 FullCalendar 在事件 .

中保存来自 Google 日历的信息
<head>
    <meta charset="utf-8">

    <title>Test</title>
    <meta name="description" content="Test">
    <meta name="author" content="Test">

    <link rel='stylesheet' href='fullcalendar/fullcalendar.css' />
    <link rel='stylesheet' href='qtip/jquery.qtip.min.css' />

    <script src='lib/jquery.min.js'></script>
    <script src='qtip/jquery.qtip.min.js'></script>     
    <script src='lib/moment.js'></script>               
    <script src='fullcalendar/fullcalendar.js'></script>
    <script type='text/javascript' src='fullcalendar/gcal.js'></script>
</head>

<body>
    <script type='text/javascript'>
    $(document).ready(function() {
        $('#calendar').fullCalendar({
            googleCalendarApiKey: '<<hidden>>',
            events: {
                googleCalendarId: '<<hidden>>'
            },
            header: {
                left:   'title',
                center: 'listWeek, agendaWeek, month',
                right:  'prev,next'
            },
            weekends: false,
            eventRender: function(event, element) {
                element.qtip({
                    content: event.description,
                    title: event.title,
                    position: {
                        my: 'center',   //Ecke des Tooltips
                        at: 'center',   //Position auf der Seite (auch Target möchlich)
                        target: $(window)
                    },
                    show: 'click'
                });
            },
            eventClick: function(event) {
                if (event.url) {
                    return false;
                }                   
            }               
        });
    });
    </script>

    <div id='calendar'></div>
</body>

我已经尝试将位置属性添加到 EventDef.defineStandardProps,但是这个应用程序没有任何效果。

EventDef.defineStandardProps({
    // not automatically assigned (`false`)
    _id: false,
    id: false,
    className: false,
    source: false,
    // automatically assigned (`true`)
    title: true,
    url: false,
    rendering: true,
    constraint: true,
    overlap: true,
    editable: true,
    startEditable: true,
    durationEditable: true,
    color: true,
    backgroundColor: true,
    borderColor: true,
    textColor: true,
    location: true
});

"fullcalendar jQuery - Possible to retrieve description from Google Calendar events?" 也对此进行了讨论,但提供的解决方案似乎已过时且不再适用。 关于此主题的所有其他主题都没有或没有结论性答案。

我需要执行哪些步骤才能使用活动地点?

在 eventRender 回调 (https://fullcalendar.io/docs/event_rendering/eventRender/) 期间,您应该能够访问 event.location,假设 Google 已在您收到的 JSON 中为您提供了该字段。您可以通过将行 console.log(JSON.stringify(event)); 插入您的 eventRender 代码来检查事件的内容,以记录您可用的事件属性。

如果数据源提供自定义属性,FullCalendar 会愉快地保留事件对象的自定义属性。获得该数据后,您可以随心所欲地将其插入到活动的 HTML 中。

我不知道您在过程中的哪个位置尝试向事件标准属性添加内容,但无论如何这没有任何意义 - 它只会预定义一个空属性,不会导致它实际填充任何东西。