Search code examples
jqueryfullcalendarfullcalendar-3

using renderevent to add future events fullcalendar


I'm trying to add an event for next month using:

var myEvent = {
  title:"my new event",
  start: $.fullCalendar.moment('2020-05-28T13:00'),
  end: $.fullCalendar.moment('2020-05-28T13:55')
};
$('#calendar').fullCalendar( 'renderEvent', myEvent );

It doesn't seem to stick.

I've tried using the demo from documentation https://fullcalendar.io/docs/v3/renderEvent-demo but it doesn't seem to work there either.

Is there a way to do this or is this a limitation?


Solution

  • As per the renderEvent documentation, you can optionally supply a third parameter named stick. The docs says this:

    Normally, the event will disappear once the calendar refetches its event sources (example: when prev/next is clicked). However, specifying stick as true will cause the event to be permanently fixed to the calendar.

    so

    $('#calendar').fullCalendar( 'renderEvent', myEvent, true );
    

    should solve your problem.