fullCalendar 1.5.3 multiple events created, unable to remove unselected events

那年仲夏 提交于 2019-12-01 06:34:41

Solved it.

It is a dead simple bug which I completely missed.

   select: function(startDate, endDate, allDay, jsEvent, view) {
        console.log("selection triggered", jsEvent.handleObj.guid)
        checkAvailability(csrfmiddlewaretoken, condo_slug, facility, startDate, endDate);
        $('#confirm').click(function(){
            confirmBooking(csrfmiddlewaretoken, condo_slug, facility.val(), startDate, endDate)
        });
    },

causes a click event to be bound to the #confirm button everytime an event is selected on the calendar. So if the user keeps selecting event without confirming, the #confirm button will keep accumulating different click events with different startDate and endDate. When the user finally hits the #confirm button after repeated indecision, all the click events fire off at one go, resulting in the previously unselected events being sent to the server as an ajax post.

To solve this, I must remember to specify $('#confirm').unbind() when the user clicks on the .cancel or .close button.

Argh... a simple solution but it took me so long to see it!

Alexandre Hübner

I had the same problem, but I solved it using this:

$( "#confirm" ).dialog({...

If I had known about unbind earlier, all the things that I had to change would not have been necessary :(

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!