Currently setting up FullCalendar using ReactJS. I can populate my calendar and the events but having trouble with the eventClick={}
. How can I populate a modal using eventClick={}
and retrieve event information?
I have managed to get the modal to appear when the event is clicked on but I cannot seem to pass any data through < this is the closest I got. I thought of perhaps greating a function where the modal fires off but I cant work out how to make it show.
Current Code
constructor() {
super();
this.state = {
modal: false
};
this.toggle = this.toggle.bind(this);
};
toggle() {
this.setState(prevState => ({
modal: !prevState.modal
}));
}
----
//I then render the calendar and modal inside the div.
<div id="calendar" class="container" ref="calendar">
<FullCalendar
header={{
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth, listWeek'
}}
selectable={true}
height={650}
aspectRatio={2}
plugins={[interaction, dayListPlugin, dayGridPlugin, bootstrapPlugin]}
themeSystem="bootstrap"
weekends={false}
displayEventTime={true}
timeZone="UTC"
events={jsonFeed}
eventRender={this.handleEventRender}
eventClick={this.toggle}
/>
<Modal isOpen={this.state.modal} toggle={this.toggle} className={this.props.className}>
<ModalHeader toggle={this.toggle}>testTitle</ModalHeader>
<ModalBody>test body</ModalBody>
<ModalFooter>
<Button color="primary" onClick={this.toggle}>Do Something</Button>{' '}
<Button color="secondary" onClick={this.toggle}>Cancel</Button>
</ModalFooter>
</Modal>
</div>
So here I get the modal appearing and disappearing when I click on the event/close button but I cannot pass the data from the event clicked through it. I hope that someone can help. I cant seem to get it to do it.