gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 08:21:04 26 4
gpt4 key购买 nike

我只是想知道如何获得结束时间,因为当我是 console.log(event) 时,结束时间为空,因此每当我删除任何内容时,它都应该返回一些结束时间周日历时间的事件。

那么如何在删除外部元素时获取结束时间,甚至从一列移动到另一列时如何获取结束时间,这将调用 eventDrop,当时我也想要结束时间。

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

预先感谢您,这是链接:

jsfiddle.net/jimil/8hqe3wxd/3/

最佳答案

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

如果外部事件没有event data associated ,然后 defaultTimedEventDurationdefaultAllDayEventDuration将会被使用。在您的 fiddle 中,正在使用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选项,如果未指定,这将导致设置结束日期。

关于javascript - 如何在 FullCalendar 中使用外部元素获取 drop 和 eventDrop 的结束时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33746441/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com