fullCalendar 1.5.3 multiple events created, unable to remove unselected events

后端 未结 2 687
逝去的感伤
逝去的感伤 2021-01-12 18:46

Using fullCalendar, I allow a user to select a day in month view in a big calendar (#cal_big) and the corresponding small calendar in day view, with hours shown (#cal_small)

相关标签:
2条回答
  • 2021-01-12 19:01

    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 :(

    0 讨论(0)
  • 2021-01-12 19:10

    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!

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