作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我只是想知道如何获得结束时间,因为当我是 console.log(event) 时,结束时间为空,因此每当我删除任何内容时,它都应该返回一些结束时间周日历时间的事件。
那么如何在删除外部元素时获取结束时间,甚至从一列移动到另一列时如何获取结束时间,这将调用 eventDrop,当时我也想要结束时间。
请不要编辑我的 fiddle ,如果可能的话创建新的 fiddle 并将其发送给我,以便我可以查看,因为我昨天花了很多时间来找出它,但找不到任何有效的解决方案。
预先感谢您,这是链接:
jsfiddle.net/jimil/8hqe3wxd/3/
最佳答案
http://jsfiddle.net/dg9gp3e3/3/
如果外部事件没有event data associated ,然后 defaultTimedEventDuration或defaultAllDayEventDuration将会被使用。在您的 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/
我是一名优秀的程序员,十分优秀!