I am trying to render events in FullCalendar v5 through a JSON array but I realised that eventRender does not work for v5. How can I do it instead then? (I do know about event render hooks but didn't understand how to use that)
<script>
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
<?php
include 'config.php';
$items = array();
$query = mysqli_query($connection, "SELECT * FROM events_table WHERE grade_id = '{$studentGradeId}' ");
while ($result = mysqli_fetch_array($query)) {
$items[] = array(
'title' => $result['event_title'],
'start' => date('Y-m-d', strtotime($result['event_date'])),
);
};
?>
var items = <?php echo json_encode($items); ?>
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'dayGridMonth',
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,dayGridWeek,dayGridDay'
},
events: items,
eventrender: function(event, calendarEl) {
calendarEl.find('.fc-title').text(event.title);
}
});
calendar.render();
});
</script>
from Event doesn't render in FullCalendar v5 with eventRender. What to use instead?
No comments:
Post a Comment