fullcalendar jQuery - Possible to retrieve description from Google Calendar events?

萝らか妹 提交于 2019-11-27 08:12:06

问题


I have setup fullcalendar to load a number of google calendar events but was wondering if there is any way to load the description or other data from the event other than the title and times?

I'd like to grab the 'description' and 'where' fields froom google calendar events and display them in a tooltip in fullcalendar.

I was thinking of trying to parse the event.url results but it doesn't work due to cross-domain ajax requests. I suppose it may be possible through a proxy php script or the crossframe jquery thing, but I'm wondering if fullcalendar provides any access to this data more cleanly? (or if anyone has a better idea)


回答1:


No idea they had this: interesting find. If you look in the gcal.js source file, there's an block of code that looks like this:

events.push({
                        id: entry['gCal$uid']['value'],
                        title: entry['title']['$t'],
                        url: url,
                        start: start,
                        end: end,
                        allDay: allDay,
                        location: entry['gd$where'][0]['valueString'],
                        description: entry['content']['$t']
                    });

My expectation is that you can use the location and description fields to do what you want.

In fact, you could probably add any other fields from the entry object that you wanted: you'd need to know what options you have, but http://code.google.com/apis/gdata/samples/cal_sample.html makes it pretty straightforward to do. I'm curious why they didn't just add the entire entry object as a field, that way ALL the data would be accessible if/when you wanted it.




回答2:


After losing my mind as to why it was so simple to add descriptions from a google calendar event, I finally found in fullcalendar.js where to put the fields. On line 3982 I changed

"<div class='fc-event-title col'>" + htmlEscape(event.title || '') +

to

 "<div class='fc-event-title col'>" + '<strong>' +
   htmlEscape(event.title || '') + '</strong><br>' +
   htmlEscape(event.description || '') +

and boom, description shows up with a little styling. Yes, it was simple and I hope this helps someone out there.




回答3:


In a recent version, you can add this way:

$('#calendar').fullCalendar({
                eventRender: function(event, element) {
                    element.description = event.description;
                },

So now, in eventMouseover or eventClick you can access to event.description.

I hope this can help.



来源:https://stackoverflow.com/questions/5811352/fullcalendar-jquery-possible-to-retrieve-description-from-google-calendar-even

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!