I have background events in my Fullcalendar, I use timeline view. I added a doubleclick trigger to handle this action, but I need to get date, where was doubleclick done.
For example, if user clicks on highlighted square, it should fire "6th of November was double clicked". (greenline is background event).
eventRender: function(info) {
$(info.el).on('dblclick', function() {
// I need to somehow get clicked date here
alert('XYZ was double clicked!');
});
});
Is here a way how to get the clicked day?
I made the solution up. It is little bit dirty, but it works.
data-date
attribute from the column in header.
$(info.el).on('dblclick', function(event) {
// get the element of the whole row
var element = $(this).parent().offset();
// get the x position of cursor
var x = event.pageX - element.left;
// get the width of column, dynamically calculated because width of viewport can be changed
var width = $('.fc-head .fc-time-area th.fc-widget-header').outerWidth() - 1;
// order number of clicked column
var number = Math.ceil(x / width);
// now we have a date of clicked date (despite we clicked background event)
alert($('.fc-head .fc-time-area th.fc-widget-header:nth-of-type(' + number + ')').data('date'));
});
Maybe it helps somebody. Just notice, this solution counts with background events - these events are clicked.