我已设置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?"进行了讨论,但所提供的解决方案似乎已过时且不再适用。 关于这个主题的每一个其他主题都没有或没有结论性答案。
我可以采取哪些步骤来使用活动地点?
答案 0 :(得分:1)
在eventRender回调期间(https://fullcalendar.io/docs/event_rendering/eventRender/),您可以访问event.location
,假设Google已在您收到的JSON中为您提供该字段。您可以将行console.log(JSON.stringify(event));
插入到eventRender代码中来检查事件的内容,以记录可用的事件属性。
如果数据源提供了事件对象,FullCalendar会愉快地保留事件对象的自定义属性。获得该数据后,您可以随意将其插入到事件的HTML中。
我不知道你在尝试将事物添加到事件标准属性的过程中的哪个位置,但无论如何都没有意义 - 它只是预先定义一个空属性,它不会导致它实际上填充了任何东西。