问题
I'm using the latest V4 version of FullCalendar and I can't seem to be able to add additional fields like description and notes in my case. I use the daygrid view and I would like two more fields to appear.
I've tried multiple options from answers here (probably for previous versions) and from the docs, including modifying the main.js from the core folder itself, where the titleHtml and timeHtml are defined (as (core.htmlEscape(eventDef.title)). I managed to add the fields or better said divs, which appear, but without content as eventDef.description is not a valid element, nor is evenDef.notes.
Where can I define these two into eventDef or how to append these fields and display them?
<script>
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var start = event.start;
var element = this;
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'dayGrid' ],
defaultView: 'dayGridWeek',
displayEventEnd:true,
columnHeaderFormat:{ weekday: 'long', month: 'long', day: 'numeric', omitCommas: true },
titleFormat: { year: 'numeric', month: 'long' },
header: {center: 'title,prev,next', right:'', left:''},
eventTimeFormat: {
hour: 'numeric',
minute: '2-digit',
meridiem: false
},
firstDay:1,
events: [
<?php get_data();?>
],
});
calendar.render();
});
</script>
Thanks in advance for any suggestions.
回答1:
eventRender: function(info) {
info.el.querySelector('.fc-desc').innerHTML = "" + info.event.description + "";
}
This solved my problem, thanks to ADyson for help.
来源:https://stackoverflow.com/questions/58592548/additional-fields-and-rows-in-fullcalendar-v4