I am attempting to implement Full Calendar into my React JS app project. What I want to do is rather than just display title, I also want the event to display a description.
I seen a previously asked question Display more Text in fullcalendar which has an answer using jquery (2nd answer) which was
$(document).ready(function() {
$('#calendar').fullCalendar({
events:
[
{
id: 1,
title: First Event',
start: .......,
end: .....,
description: 'first description'
},
{
id: 2,
title: 'Second Event',
start: .......,
end: .....,
description: 'second description'
}
],
eventRender: function(event, element) {
element.find('.fc-title').append("<br/>" + event.description);
}
});
}
I tried to change that inline with my code:
<div id="calendar" class="container">
<FullCalendar
defaultView="dayGridMonth"
height={650}
aspectRatio={2}
plugins={[dayGridPlugin]}
themeSystem='bootstrap4'
weekends={false}
events={[
{ title: 'event1', description: 'Test data', date: '2019-05-13' },
{ title: 'event 2', date: '2019-04-02' }
]}
eventRender={
function(element)
{
element.find('.fc-title').append("<br/>" + "asdasd");}
}
/>
</div>
Without the 'eventRender' the calendar works fine, but I just need to get that one little bit working, I am probably missing something really obvious but I have been staring and trying different things and getting nowhere. Hopefully someone can advise how I can do it.
UPDATE Based upon your answer I have tried this but this does not work. Can you please provide further assistance? I appreciate it.
class Calendar extends React.Component {
render() {
return (
<div id="calendar" class="container" ref="calendar">
<FullCalendar
selectable={true}
defaultView="dayGridMonth"
height={650}
aspectRatio={2}
plugins={[interaction, dayGridPlugin, bootstrapPlugin]}
themeSystem="bootstrap"
weekends={false}
displayEventTime={true}
timeZone="UTC"
events={[
{ title: 'Early Bird Registration Deadline', description: 'asdasd', date: '2019-05-13' },
{ title: 'event 2', description: 'asdasdasd', date: '2019-04-02' }
]}
eventRender={this.EventDetail}
/>
</div>
)
}
EventDetail = ({ event, el }) => {
const content = <div>{event.title}<div>{event.description}</div></div>;
ReactDOM.render(content, el);
return el;
};
}
export default Calendar;