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