我希望绑定到时隙上的双击事件,以便显示警报。这是我当前使用的代码
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: '2014-11-12',
editable: true,
eventLimit: true,
events: [
{
title: 'All Day Event',
start: '2014-11-01'
}
],
eventRender: function(event, element) {
element.bind('dblclick', function() {
alert("dblclick event");
});
}
});
它使用 eventRender
选项绑定事件的双击事件,并且有效。 但是我想绑定到时隙上的双击事件以显示上面的警报。我该怎么做呢?
我发现使用dayClick选项可以解决此问题:
var delay = 300, clicks = 0, timer = null;
dayClick: function (date, allDay, jsEvent, view) {
clicks++; //count clicks
if(clicks === 1) {
timer = setTimeout(function() {
alert('Single Click'); //perform single-click action
clicks = 0; //after action performed, reset counter
}, delay);
} else {
clearTimeout(timer); //prevent single-click action
alert('Double Click'); //perform double-click action
clicks = 0; //after action performed, reset counter
}
}