如何在FullCalendar中使用外部元素获取drop和eventDrop的结束时间?

我只想知道如何获得结束时间,因为我是console.log(事件),然后结束时间为null,所以每当我在周日历时删除任何事件时它应该返回一些结束时间。

那么如何在外部元素的丢弃上获得结束时间,甚至当从一列移动到另一列时将调用eventDrop,那时我也想要结束时间。

如果可能的话,请不要编辑我的小提琴并创建新的小提琴并将其发送给我以便我可以看一看,因为我昨天花了很多时间来找出它但却找不到任何有效的解决方案。

提前谢谢,这里是链接:

jsfiddle.net/jimil/8hqe3wxd/3/ 

http://jsfiddle.net/dg9gp3e3/3/

如果外部事件没有关联事件数据 ,则将使用defaultTimedEventDuration或defaultAllDayEventDuration 。 在您的小提琴中,正在使用defaultTimedEventDuration,因为事件的allDay未设置为true。 您可以通过获取默认值

 var defaultDuration = $('#calendar').fullCalendar('option', 'defaultTimedEventDuration'); defaultDuration = moment.duration(defaultDuration); // to add to date need to convert to a moment duration 

eventDrop的一个例子

  eventDrop: function(event, delta, revertFunc) { //inner column movement drop so get start and call the ajax function...... console.log(event.start.format()); console.log(event.id); var defaultDuration = moment.duration($('#calendar').fullCalendar('option', 'defaultTimedEventDuration')); // get the default and convert it to proper type var end = event.end || event.start.clone().add(defaultDuration); // If there is no end, compute it console.log('end is ' + end.format()); //alert(event.title + " was dropped on " + event.start.format()); }, 

对于掉落事件:

 drop: function(date) { //Call when you drop any red/green/blue class to the week table.....first time runs only..... console.log("dropped"); console.log(date.format()); console.log(this.id); var defaultDuration = moment.duration($('#calendar').fullCalendar('option', 'defaultTimedEventDuration')); var end = date.clone().add(defaultDuration); // on drop we only have date given to us console.log('end is ' + end.format()); } 

另一个选项是使用forceEventDuration选项,如果没有指定,将导致结束日期设置。