FullCalendar v4 将 onclick eventListener 添加到 eventLimitClick



我有一个使用FullCalendar v4 js的自定义开发,但我遇到了eventLimitClick方法的问题。

当我单击它时,我希望弹出窗口中显示的所有事件都有一个自定义onclickeventListener,以便我在另一个自定义弹出窗口中显示此当前事件的其他信息。

这是我到目前为止的方法:

eventLimitClick : function(info){
info.segs.forEach(function(seg){
seg.el.querySelector('div.fc-content').addEventListener('click', function(event){
console.log('event definition', event);
});
});
return "popover";
}

但这是在将侦听器添加到我已经在日历中看到的元素中。我也尝试使用hiddenSegs而不是赛格,但它不起作用。

那么有没有办法实现这一点,而不必创建包含所有事件的自定义弹出窗口?

**编辑 ** [包含的代码]

日历对象

{
locale : 'en',
plugins : ['dayGrid','timeGrid','list','interaction'],
header : {
left : 'prev,next today',
center : 'title',
right : 'dayGridWeek, dayGridMonth, dayGridDay'
},
allDaySlot : false,
aspectRatio : 1.8,
displayEventTime : false,
editable : false,
navLinks : true,
eventLimit : true,
views : {
dayGridMonth : {
eventLimit : 2
}
},
events : this.eventLIST,
datesRender : this.calendarviewRender,
eventClick : this.calendareventClick,
eventRender : this.calendareventRender
}

datesRendereventClickeventRender功能:

calendarviewRender = (info) => {
//set current and end dates
this.endDate = info.view.activeEnd;
this.currentDate = info.view.activeStart;
//retrieve fresh event/task info
this.refreshCalendar();
}
calendareventClick = (info) => {
this.info = {id : info.event.id,
tipo : info.event.extendedProps.tipo,
tipoObj : info.event.extendedProps.tipoObj,
isClosed : info.event.extendedProps.isClosed && info.event.extendedProps.isClosed !== null ? (info.event.extendedProps.isClosed === 'false' ? false : true) : false,
campos : info.event.extendedProps.lCamposInfo};
//allow second button
this.info.displaysecondbutton = !this.info.isClosed && this.info.tipoObj === 'Task';
//allow popup display
this.allowpopup = true;
info.jsEvent.preventDefault();
}
calendareventRender = (info) => {       
let html = "<i class='fa fa-" + info.event.extendedProps.icon + " fa-lg'></i>";
info.el.querySelector('div.fc-content').style.cssText = 'height: 100%;';
//if month view apply padding
if(info.view.type.includes('dayGrid')) info.el.querySelector('div.fc-content').classList.add('slds-p-around_x-small');
//center elements
info.el.querySelector('div.fc-content').classList.add('slds-align_absolute-center');
//append icon
info.el.querySelector('div.fc-content').innerHTML = html;
}

我还删除了eventLimitClick.

根据您的评论,我看到您正在使用闪电网络组件。

在与LWC合作销售时,我遇到了与您相同的问题。

我能够通过在daygrid包中编辑main.js并在隐藏Popover时添加延迟来解决此问题。

这是代码片段

function Popover(options) {
var _this = this;
this.isHidden = true;
this.margin = 10; // the space required between the popover and the edges of the scroll container
// Triggered when the user clicks *anywhere* in the document, for the autoHide feature
this.documentMousedown = function (ev) {
if (_this.el && !_this.el.contains(ev.target)) {
setTimeout(function () {
_this.hide();
}, 1000);
}
};
this.options = options;
}

函数从主.js的第 100 行开始。 我正在使用全日历 v4

最新更新