简体   繁体   English

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

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

I just wanted to know how can i get the end time as when I am console.log(event) then end time comes as null so it should return me some end time whenever I drop any event on week calendar time. 我只是想知道如何获得结束时间,就像我在console.log(event)时那样, 结束时间为null,因此每当我删除周历中的任何事件时,它应该返回一些结束时间。

So how to get end time on drop of external element or even when move from one column to another column which will invoke eventDrop and at that time I also want end time. 因此,如何在外部元素下降时甚至在从一列移至另一列时调用eventDrop来获得结束时间,那时候我也想要结束时间。

Please don't edit my fiddle and create new one if possible and send it to me so that I can have a look as I spent lot of time yesterday to find out it but couldn't find any working solution on this. 请不要编辑我的小提琴,如果可能的话请创建一个新的小提琴,然后将其发送给我,以便让我看一下,因为昨天我花了很多时间来查找它,但是找不到任何可行的解决方案。

Thank you in advance and here is the link: 预先谢谢你,这里是链接:

jsfiddle.net/jimil/8hqe3wxd/3/

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

If the external event does not have event data associated , then the defaultTimedEventDuration or defaultAllDayEventDuration will be used. 如果外部事件没有关联的事件数据 ,则将使用defaultTimedEventDurationdefaultAllDayEventDuration In your fiddle, the defaultTimedEventDuration is being used since allDay is not set to true for the event. 在您的小提琴中,由于没有将allDay设置为true,因此使用了defaultTimedEventDuration。 You can get the default value by 您可以通过以下方式获取默认值

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

An example for eventDrop 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());

        },

For drop event: 对于掉落事件:

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());
        }

Another option is to use the forceEventDuration option, which will cause an end date to get set if none is specified. 另一个选项是使用forceEventDuration选项,如果未指定结束日期,则会导致设置结束日期。

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

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