javascript-从dayClick的后台事件获取ID和标题
作者:互联网
$('#calendar').fullCalendar({
header:
{
left: 'prev,next today',
center: 'title',
right: 'agendaWeek,agendaDay'
},
events: [
{
id: 'availableForMeeting',
start: '2015-02-11T10:00:00',
end: '2015-02-11T16:00:00',
rendering: 'background'
},
{
id: 'availableForMeeting',
start: '2015-02-13T10:00:00',
end: '2015-02-13T16:00:00',
rendering: 'background'
}
]
dayClick:
function(date, jsEvent, view) {
if (jsEvent.target.classList.contains('fc-bgevent')) {
//I can find out if it is a backround event.
}
}
});
我可以确定这是否是一次背景事件,但如何获取它的ID?
解决方法:
将dayClick与eventRender
回调结合在一起.
eventRender: function(event,element){
if(event.rendering == "background"){
element.data(event); //store the event data inside the element
}
},
dayClick: function(date, jsEvent) {
if (jsEvent.target.classList.contains('fc-bgevent')) {
console.log($(jsEvent.target).data());
}
},
标签:fullcalendar,javascript 来源: https://codeday.me/bug/20191028/1952742.html