开发者

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

开发者 https://www.devze.com 2023-02-28 23:51 出处:网络
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 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)

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


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消