我想知道是否有可能删除事件并根据className再次呈现fullcalendar。
我现在有一些看起来像这样的东西,它似乎没有按计划运作。
if(bla = bla){
displayCalData(myJsonData);
}
function displayCalData(json){
//Define the cal ID to feed data too.
var calendar = $('#calendar');
calendar.fullCalendar('removeEvents',myRemove);
$.each(json, function(i, item) {
//Create block render
var displayText = item.displayName;
var eventObject = {
title: displayText,
start: item.startDate,
end : item.endDate,
allDay:true,
color: '#BABBBF',
editable : false,
className : "user_block"
};
calendar.fullCalendar('renderEvent', eventObject, true);
});
}
function myRemove(event) {
return "user_block" === event.className; // ensure your events have this custom class !
}
另外要注意的是,onLoad fullCalendar还会加载来自单独调用的其他事件数据。
有没有办法可以使用className" user_block"删除日历上的所有事件。并使用新数据重新呈现日历?
感谢您的阅读和帮助。
答案 0 :(得分:3)
直接将函数添加到removeEvents似乎可以解决问题
calendar.fullCalendar('removeEvents', function(event) {
return event.className == "user_block";
});