Removing specific events with removeEvents method

后端 未结 1 1177
我寻月下人不归
我寻月下人不归 2021-02-09 08:23

I\'ve just started out using this plugin and I am having some trouble removing events that I have just created. I can delete all the events when using eventClick, but not partic

相关标签:
1条回答
  • 2021-02-09 08:49

    You can do this in 2 ways:

    1) Set a unique ID to each of your events and pass those IDs to the removeEvents call.

    eventClick: function (calEvent, jsEvent, view) {           
        $('#calendar').fullCalendar('removeEvents', calEvent._id);
    }
    

    Here _id is the unique ID fullCalendar generates.

    2) Pass a filter function to delete the event you want.

    Considering that you are trying to do this in eventClick, I would suggest you use the 2nd. An example to your case is as follows:

    eventClick: function (calEvent, jsEvent, view) {
        $('#calendar').fullCalendar('removeEvents', function (calEvent) {
            return true;
        });
    }
    

    Here the filter function passed to removeEvents accepts the event you want to delete and returns true. Since you are doing this in eventClick, all you have to do is pass calEvent.

    Hope this helps!

    0 讨论(0)
提交回复
热议问题