Fullcalendar SetDate on an event with AllDay doesn't work

819 Views Asked by At

The documentation states that you can use the function like this:

event.setDates( start, end, [ options ] )

Where [ options ] accepts a plain object with a property of allDay of either true of false, however I can't seem to make this work, as I've tried multiple ways to do this. While events that have that property set by setDate() don't output any errors, they don't appear in the calendar as well.

What I have tried:

  1. Storing an object in a variable and using that variable:
year = calendar.getDate().getFullYear();
var all_day_object = {
    allDay: true,
};
calendar.getEventById('new_year').setDates(`${year}-01-01`, `${year}-01-01`, all_day_object);
  1. Setting it as true and hoping for the best:
year = calendar.getDate().getFullYear();
calendar.getEventById('new_year').setDates(`${year}-01-01`, `${year}-01-01`, true);
  1. Creating an object with brackets in the same line:
year = calendar.getDate().getFullYear();
calendar.getEventById('new_year').setDates(`${year}-01-01`, `${year}-01-01`, {allDay: true});

While I can achieve the same effect with this code:

year = calendar.getDate().getFullYear();
calendar.getEventById('new_year').setDates(`${year}-01-01`, `${year}-01-01`);
calendar.getEventById('new_year').setAllDay(true);

I want to do in a one line to simplify my code.

0

There are 0 best solutions below