1
votes

In "FullCalendar" I could add an event using "addEventSource" by array manually, however, I could not succeed adding the event through Google Calendar ID.

$('#calendar').fullCalendar("addEventSource",{
    events:  [
      {
        title  : 'event1',
        start  : '2019-02-01'
      }
    ]
  });

THE BELOW SNIPPET NOT GETTING THROUGH. PLS ASSIST

  $('#calendar').fullCalendar("addEventSource",{
    events:  {
      googleCalendarId: '[email protected]',
    }
  });

FYI by FUllcalendar: Source may be an Array/URL/Function just as in the events option. Events will be immediately fetched from this source and placed on the calendar.

1

1 Answers

0
votes

Firstly please ensure you followed all the steps in the documentation (https://fullcalendar.io/docs/google-calendar) beforehand otherwise it won't work.

Secondly, your object structure is wrong. The events wrapper should not be there when specifying an event source. Perhaps you confused the events option in fullCalendar as being part of the structure required for an event source object, which is documented here: https://fullcalendar.io/docs/event-source-object

Specifically it documents the structure for a google calendar to be the source:

{
  googleCalendarId: '[email protected]',
  color: 'yellow',   // an option!
  textColor: 'black' // an option!
}

So I suggest you change your code as follows, to match the documented object structure. Basically you just remove the erroneous events bit:

$('#calendar').fullCalendar("addEventSource", {
  googleCalendarId: '[email protected]',
});