piernik
piernik

Reputation: 3657

Adding classes to an event

I want to add classes to event. So I use eventContent in CalendarOptions. But fullcalendar seems to freeze when I use:

private eventRenderFunc(info: EventResizeDoneArg | EventDropArg) {
    info.event.setProp('classNames', 'zadanie');
}

How can I add custom classes to event in fullcalendar@5 ?

Here is sample: https://codepen.io/piernik/pen/NWNvrpq?editors=0011

Upvotes: 0

Views: 586

Answers (1)

ADyson
ADyson

Reputation: 61914

The evenContent hook isn't really intended for setting properties of the event object - it's there to help you control the HTML which is rendered from that event object.

Since your're simply adding the same property to every event object rather than directly manipulating the HTML, a more appropriate place for that would be the eventDataTransform callback (see https://fullcalendar.io/docs/eventDataTransform).

eventDataTransform: eventTransformFunc,

and

function eventTransformFunc(event) {
  console.log(event);
  event.classNames = "zadanie";
  return event;
}

This works nicely - demo: https://codepen.io/ADyson82/pen/KKzvBjm

Upvotes: 1

Related Questions