gpt4 book ai didi

javascript - FullCalendar,4.2 - 如何更改 eventClick 函数上的事件类

转载 作者:行者123 更新时间:2023-12-02 21:45:22 25 4
gpt4 key购买 nike

我试图在单击事件时更改事件的 CSS 类,但运气为零。这是我的 JS:

var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'dayGrid', 'timeGrid', 'list' ],
header: {
left: 'prevYear,prev,next,nextYear',
center: 'title',
right: 'today dayGridMonth,timeGridWeek,timeGridDay,listWeek'
},
defaultView: 'dayGridMonth',
eventLimit: true,
views: {
month: {
eventLimit: 2
}
},
eventClick:function(info){
var id = info.event.extendedProps.timeslotid;
$.ajax({
url: 'index.php?option=com_cases&task=shifts.timeslotform&id='+id,
type: 'post',
dataType: 'html',
async: true,
success: function(response){
if (response) {
info.setProp( 'classNames', 'selected' ); // here's where the issue is
$('#sbcontent').empty();
$('#sbcontent').append(response);
}
}
});
},
events: 'index.php?option=com_cases&task=shifts.buildevents',
eventTimeFormat: { // like '14:30:00'
hour: 'numeric',
minute: '2-digit',
hour12: true
}
});

calendar.render();

我尝试了以下方法,但都会导致类似以下内容的 JS 错误:“Uncaught TypeError: info.setProp is not a function”。

1) info.setProp( 'classNames', 'selected' );
2) info.el.setProp( 'classNames', 'selected' );
3) $(this).setProp( 'classNames', 'selected' );
4) $(this).addClass("selected");

我发现了一篇类似的帖子,但接受的答案没有添加或更改类(class)。相反,他们只是改变了事件的背景颜色。但我不想那样做。我宁愿向事件添加 CSS 类。

类似帖子:FullCalendar, how to change event class on eventClick function

感谢任何帮助!

最佳答案

info.event 是对 Event 的引用。所以你必须执行info.event.setProp('yourProp', 'yourValue)。请记住,classNames 属性是一个数组,而不是一个字符串。

关于javascript - FullCalendar,4.2 - 如何更改 eventClick 函数上的事件类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60264003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com