繁体   English   中英

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

[英]How to get end time on drop and eventDrop with external elements in FullCalendar?

我只是想知道如何获得结束时间,就像我在console.log(event)时那样, 结束时间为null,因此每当我删除周历中的任何事件时,它应该返回一些结束时间。

因此,如何在外部元素下降时甚至在从一列移至另一列时调用eventDrop来获得结束时间,那时候我也想要结束时间。

请不要编辑我的小提琴,如果可能的话请创建一个新的小提琴,然后将其发送给我,以便让我看一下,因为昨天我花了很多时间来查找它,但是找不到任何可行的解决方案。

预先谢谢你,这里是链接:

jsfiddle.net/jimil/8hqe3wxd/3/

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

如果外部事件没有关联的事件数据 ,则将使用defaultTimedEventDurationdefaultAllDayEventDuration 在您的小提琴中,由于没有将allDay设置为true,因此使用了defaultTimedEventDuration。 您可以通过以下方式获取默认值

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选项,如果未指定结束日期,则会导致设置结束日期。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM