Search code examples
javascriptjqueryfullcalendarfullcalendar-5

How to set attribute to the fullcalendar (v5) events?


In FullCalendar v5 eventRender callback was removed.

I decided to use eventDidMount from Event Render Hooks, but don't know how to properly set an attribute

var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
  eventClick: function (info) {
    $('.popover-event' + info.event.id).popover('show')
  },

  eventResize: function (info) {
    console.log(info);
  },



//HERE
  eventDidMount: function (event) {
    // element.attr('title', event.tip);
    console.log('atr', event.el.attributes)
  },





  timeZone: 'UTC',
  slotEventOverlap: false,
  eventColor: '#c1c1c1',
  editable: false, //editableni ko'rish kerak
  schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
  initialView: 'resourceTimeGridTwoDay1',
  nowIndicator: true,
  // now:moment().format(),
  initialDate: moment().format('YYYY-MM-DD'),
  allDaySlot: false,
  slotMinTime: '08:00:00',
  slotMaxTime: '18:00:00',
  selectable: true,
  locales: 'ru',
  headerToolbar: false,
})

Solution

  • I searched a little and found the answer

    eventDidMount: function (event) {
        $(event.el).attr('data-trigger', 'focus')
        $(event.el).attr('tabindex', 0)
    }