简体   繁体   中英

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.

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.

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/

If the external event does not have event data associated , then the defaultTimedEventDuration or defaultAllDayEventDuration will be used. In your fiddle, the defaultTimedEventDuration is being used since allDay is not set to true for the event. 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: 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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