我在我的全部日历中有背景事件,我使用时间线视图。我添加了一个doubleclick触发器来处理这个操作,但是我需要得到日期,doubleclick在哪里完成的。
例如,如果用户点击突出显示的广场,它应该会触发“11月6日被双击”。(绿线是背景事件)。
eventRender: function(info) {
$(info.el).on('dblclick', function() {
// I need to somehow get clicked date here
alert('XYZ was double clicked!');
});
});
这里有办法让点击的一天吗?
发布于 2020-07-28 23:52:48
我想出了解决办法。有点脏,但很管用。
我正在用鼠标计算coordinates
中的列获得data-date
属性的日期。
。
$(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'));
});
也许能帮上忙。请注意,此解决方案与后台事件一起计算--这些事件是被单击的。
https://stackoverflow.com/questions/63124280
复制相似问题