Probably overlooking something simple, but haven't been able to work it out yet via the docs or searching this forum.
I've created a custom component using FullCalendar to expand on the possibilities of the calendar component in Retool.
I'm looking to pass the week number of the visible week in the calendar back to a temporary state variable in retool. The week number of the current view can be called using getDate() from within the component.
My iframe code looks like this:
<script src="https://cdn.jsdelivr.net/npm/fullcalendar@5.11.3/main.min.js"></script>
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fullcalendar@5.11.3/main.min.css">
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css' rel='stylesheet'>
<link href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css' rel='stylesheet'>
<script>
window.Retool.subscribe(function(model, modelUpdate ) {
if (!model) { return }
var calendarEl = document.getElementById('react');
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'timeGridWeek',
events: model,
datesSet: function(info) {
console.log(moment(calendar.getDate()).isoWeek())
}
});
calendar.render();
})
</script>
<div id="react"></div>
With the code above, the console logs work as intended, so when I change to a different week the correct week is printed to the console (e.g. 45). I'm looking to pass this value to a temporary state in retool which I've called selected_week_num
.
Can anyone point me in the right direction?