0
votes

My calendar initialize with events from ajax-php script. The events has a simple css class with green background-color for available events and red background-color for not available events.

I need that when I click on a green event, it will turn red to set this not available.

var calendarEl = document.getElementById('calendar');
$('#calendar').empty();
var calendar = new FullCalendar.Calendar(calendarEl, {
    plugins: ['timeGrid'],
    defaultView: 'timeGridWeek',
    minTime: '08:00:00',
    maxTime: '18:00:00',
    allDaySlot: false,
    weekends: false,
    defaultDate: jdata.defaultDate,
    contentHeight: 'auto',
    locale: 'es',
    eventClick: function (info) {
        var dia = moment(info.event.start).format("DD/MM/YYYY");
        var hora = moment(info.event.start).format("HH:mm");

        if (info.event.classNames[0] == 'completo') {
            return;
        }

        reservarSala(info.event, sala_id);
    },
    events: jdata.events
});
calendar.render();
1

1 Answers

1
votes

The documentation says the HTML element for the event can be accessed using el:

var check_color = info.el.style.background

if (check_color == "green") {
    info.el.style.background = "red"
} else {
    info.el.style.background = "green"
}