'Trigger the remove() of an event outside of fullcalendar declaration

I'm working on a Filemaker webviewer and it display a calendar that is generated using Fullcalendar library in js. My issue is when I drag & drop an event into my calendar it open a window that is used to create my event from there and the problem is that when the event is dropped it display an event which is not completely defined because I finalize it creation in the Filemaker window, and I want to add the possibility of removing this event from the calendar dynamically when we quit the Filemaker window.

I already know how to trigger a script when I click on the exit button of the window and I already made a script in js that works fine, the final problem here is that I need to send the calendar object to my script for receive the actual event I will remove. I don't know how to store my calendar object when I'm not in the fullcalendar declaration I've tried to get it from the DOM directly but it return only the html not the js object with all the data.

Here is my calendar with the window open after drag & drop an event:

I would like to remove the yellow event if I click on the red cross of the window

Below is my function for removing an event using the calendar object:

function removeTemporaryEvent(calendar){
    let events = calendar.getEvents();
    for (var event in calendar.getEvents()) {
        if (events[event]._def.extendedProps.temporary === 'true'){
            events[event].remove();
            calendar.render();
        }
    }
}

It should look like this below I give no parameter to my function so Filemaker can trigger it without knowing what calendar is and in the function we get the calendar from the already existing object that fullcalendar created.

function removeTemporaryEvent(){
    let calendar = */getting calendar/*;
    let events = calendar.getEvents();
    for (var event in calendar.getEvents()) {
        if (events[event]._def.extendedProps.temporary === 'true'){
            events[event].remove();
            calendar.render();
        }
    }
}

Thanks for reading, if you have answers to this issue please let me know. (Sorry if my English is bad by the way)

[EDIT] : bellow the declaration of my calendar with the drag & drop

<script>

document.addEventListener('DOMContentLoaded', function() {
    var Calendar = FullCalendar.Calendar;
    var Draggable = FullCalendar.Draggable;

    var containerEl = document.getElementById('external-events');
    var calendarEl = document.getElementById('calendar');

    new Draggable(containerEl, {
        itemSelector: '.fc-event',
        eventData: function(eventEl) {
            return {
                title:eventEl.title,
                color:eventEl.dataset.color,
                textColor:'white',
                idstage:eventEl.dataset.idstage,
                temporary:eventEl.dataset.temporary
            };
        }
    });
    
    let calendar = new Calendar(calendarEl, {


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source