簡體   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