FullCalendar 3.9.0升级后eventClick失效,eventRender能否实现事件弹窗?
Can FullCalendar's
eventRender be used to implement event popup functionality? Absolutely! You can definitely use eventRender to add click-triggered popup functionality for your events, which is a great workaround if your eventClick handler is being ignored after upgrading to FullCalendar 3.9.0. Here's how to make it work:
Step 1: Attach a click handler directly via eventRender
The eventRender callback runs every time an event is rendered on the calendar. This lets you bind a click event straight to the event's DOM element, avoiding any potential conflicts that might be blocking your original eventClick logic.
Example Implementation
$('#calendar').fullCalendar({ // Your existing config (Google Calendar sources, view settings, etc.) eventRender: function(event, element, view) { // Bind click action to the rendered event element element.click(function(e) { // Trigger your popup function with the event data showEventInformation(event); // Block the default redirect to Google Calendar e.preventDefault(); return false; }); } });
Why this approach works
- Unlike
eventClick, which relies on FullCalendar's internal event delegation, binding directly to the event element ensures your handler is attached directly to the DOM node—making it far less likely to be overridden or ignored by updates or conflicting scripts. - You’ll still have full access to the
eventobject (including description, start/end times, and all other event details) to pass to yourshowEventInformationfunction.
Quick Tips
- Double-check that your
showEventInformationfunction is properly defined and accessible in the same scope as theeventRendercallback. - If the default Google Calendar redirect is still happening, confirm both
e.preventDefault()andreturn falseare included to fully stop the default action.
内容的提问来源于stack exchange,提问作者ridgedale




