我正在使用FullCalendar库来构建计划。我已启用editable
属性,因此我可以调整事件的大小。我使用这个事件监听器来做我想做的事情:
eventResize: function(event,dayDelta,minuteDelta,allDay,revertFunc) {
//Some code goes here
}
但是我想知道是否有办法检测调整大小是在事件的开始日期还是结束日期发生的?
答案 0 :(得分:1)
这段代码更有效:
eventResizeStart: function(event) {
startDateOnStart = event.start.format();
endDateOnStart = event.end.format();
},
eventResize: function( event, delta, revertFunc, jsEvent, ui, view ) {
startDateOnStop = event.start.format();
endDateOnStop = event.end.format();
if (startDateOnStart != startDateOnStop){
alert ('The resize took place at Start!');
} else if (endDateOnStart != endDateOnStop ){
alert ('The resize took place at End!');
}
}
答案 1 :(得分:0)
好吧,我自己找到了解决方案。我们可以在eventResizeStart
和eventResizeStop
上保留事件期间的记录,然后我们会比较这些记录。我的意思是这样的:
eventResizeStart: function(event) {
startDateOnStart = event.start;
endDateOnStart = event.end;
}
然后
eventResizeStop: function(event) {
// I added 1 sec delay because in my experience the event object needs some time to update.
setTimeout(
function(){
startDateOnStop = event.start;
endDateOnStop = event.end;
//Now let's compare the dates.
if (startDateOnStart != startDateOnStop){
alert ('The resize took place at Start!');
// Do some things here.
} else if (endDateOnStart != endDateOnStop ){
alert ('The resize took place at End!');
}
}, 1000);
}