integration google calendar with fullcalendar

六月ゝ 毕业季﹏ 提交于 2020-01-05 08:10:36

问题


i am working on a project symfony3 to integrate googleCalendar with fullcaldendar. I'd like to use the googlecalendar to feed the fullcalendar to show all the events i had in googlecalendar,and then each time when i change a event in fullcalendar, it will be changed also in googlecalendar. So the step is to get the google events from googleCalendar which i have done already and i have tried to make it in format of json:

$myjsonfile:

[{
"title": "Rdv Ecole",
"start": "2017-11-13T10:00:00+01:00",
"end": "2017-11-13T12:00:00+01:00"
 }, {
"title": "testing functions",
"start": "2017-11-20T13:15:00+01:00",
"end": "2017-11-20T14:15:00+01:00"
 }, {
"title": "another test",
"start": "2017-11-20T17:30:00+01:00",
"end": "2017-11-20T18:30:00+01:00"
 }, {
"title": "reuinion data vc",
"start": "2017-11-21T09:00:00+01:00",
"end": "2017-11-21T10:00:00+01:00"
 }]

Because i am using symfony3, so i make a

 return $this->render('calendar/loadcalendar.html.twig',['gevents'=>$myjsonfile]);

And then in my page to show the event:

$(document).ready(function() {

        $('#calendar').fullCalendar({
            defaultView: 'agendaWeek',
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
            navLinks: true, // can click day/week names to navigate views
            selectable: true,
            selectHelper: true,
            select: function(start, end) {
                var title = prompt('Event Title:');
                var eventData;
                if (title) {
                    eventData = {
                        title: title,
                        start: start,
                        end: end
                    };
                    $('#calendar').fullCalendar('renderEvent', eventData, true); // stick? = true
                }
                $('#calendar').fullCalendar('unselect');
            },

            eventLimit: true, // allow "more" link when too many events
            eventSources: [
                {
                    url: "http://localhost/prog/web/app_dev.php/calendar/load",
                    dataType: "json",
                    method: 'GET'
                }
            ],
            eventClick: function(event) {

                var title = prompt('Change Event title:');
                event.title = title;
                $('#calendar').fullCalendar('updateEvent', event);

            }
        });

Now the problem is that i can't load the events from the json i have send,so can someone give me some advices? thanks


回答1:


In my project, I do it this way:

$('#calendar').fullCalendar({
    /* [...] */
    events: "{{ path('ajax_calendar_load') }}",
    /* [...] */

And my load action return regular json:

    $response = new JsonResponse();
    $response->setContent($events);
    return $response;


来源:https://stackoverflow.com/questions/47390422/integration-google-calendar-with-fullcalendar

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