Fullcalendar version is 3.9.0.
When I double click button 'Prev' or 'Next' on top left corner, the view will go backward or forward two months. That's fine. But the events in the view retrieved through Promise are duplicate in this case. They are even trippled following quick clicks.
I tried to use 'event.stopPropagation();' to stop event bubbling but no luck. After transformed event dblclick event into single click, Fullcalendar seemed did not respond accordingly. It may skip into next year or previous year if double click is triggered. It still skip months and showed duplicate events.
$("button[aria-label='prev']").on('dblclick', function(e) {
e.stopPropagation();
});
For retrieving events in Fullcalendar, please find the code as following.
$('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay,listMonth,listYear'
},
viewRender : function(view, element) {
viewRenderInit(view, element);
},
...
});
//when switch/init view, only get events related to current calendar view
let viewRenderInit = function (view, element) {
$('#calendar').fullCalendar( 'removeEvents');
let u = '/getbookings';
let r = '';
let _common_params = '_token='+$("[name=\'_token\']").val()+'&view='+view.name+'&time_frame='+ view.title;
get(u, _common_params).then(function(response) {
r = response;
$('#calendar').fullCalendar( 'addEventSource', JSON.parse(r));
}, function(error) {
console.error("Failed!", error);
});
}
let get = function(url, params) {
return new Promise(function(resolve, reject) {
var req = new XMLHttpRequest();
req.open('GET', url+"?"+params, true);
req.onload = function() {
if (req.status == 200) {
resolve(req.response);
}
else {
reject(Error(req.statusText));
}
};
req.onerror = function() {
reject(Error("Network Error"));
};
req.send();
});
}
I expect disable event dblclick for button 'Prev' or 'Next'. Alternately, disalbe retrieving duplicate events through Promise via Ajax call .
Appreciate for any suggestion.