FullCalendar,如何更改eventClick函数上的事件类 [英] FullCalendar, how to change event class on eventClick function
本文介绍了FullCalendar,如何更改eventClick函数上的事件类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的日历使用ajax-php脚本中的事件初始化.这些事件具有一个简单的css类,具有可用事件的绿色背景色和不可用事件的红色背景色.
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();
推荐答案
HTML的文档可以使用el
访问该事件的元素:
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"
}
这篇关于FullCalendar,如何更改eventClick函数上的事件类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文