0
votes

I've tried this code but it shows JS error.

eventDragStop: function(event) {
    console.log(event);
    console.log(event._id);
    let eve = event.jsEvent;
    //console.log(eve);
    var trashEl = jQuery('#CalendarTrash');
    var ofs = trashEl.offset();

    var x1 = ofs.left;
    var x2 = ofs.left + trashEl.outerWidth(true);
    var y1 = ofs.top;
    var y2 = ofs.top + trashEl.outerHeight(true);

    if (eve.pageX >= x1 && eve.pageX <= x2 &&
        eve.pageY >= y1 && eve.pageY <= y2) {
        if (confirm("Are you sure to  detete " + event.title + " ?")) {
            //pour annuker les informations
            $('#calendar').FullCalendar('removeEvents', event._id);
        }
    }
}

It shows error

Uncaught TypeError: $(...).FullCalendar is not a function

, event.title and event._id are blank everything else is working fine.

As per documentation it has https://fullcalendar.io/docs/v3/removeEvents it has

.fullCalendar( ‘removeEvents’ [, idOrFilter ] )

and this fullCalendar is deprecated as per this documentation https://fullcalendar.io/docs/upgrading-from-v3 now i need the syntax to remove the event on eventDragStop

1
fullcalendar.io/docs/Event-remove . And also fullcalendar.io/docs/eventDragStop (because the function signature has changed in v4 - the event is now just a sub-property of the supplied parameter, which is named info, for clarity). Did you try reading the documentation for version 4? It's not hard to find. The job of the volunteers here is not to google things or to read the docs on your behalf.... . - ADyson
If you did read the documentation, and there was something you didn't understand, please mention it. But judging by this code attempt, it looks like you didn't look at it, or not carefully enough, otherwise you would have noticed the available methods, and noticed the changes to the callback signature. - ADyson
@ADyson Thank you its now working. I read the documentation also for it. - namco

1 Answers

2
votes

It seems to me that all you need you can find by looking at the link your provided about how to migrate to fullcalendar-4. There are at least two things you need to change:

  • The parameter passed to your callback for eventDragStop is now an object with { event, jsEvent, view } (as explained here)
  • To remove an event: "retrieve an Event object and then call its remove method:"
var event = calendar.getEventById('a');
event.remove();