使用addEventSource时,FullCalendar v.2.2.6'hasTime'未定义错误 [英] FullCalendar v.2.2.6 'hasTime' undefined error when using addEventSource
问题描述
我目前正在测试 FullCalendar
(版本2.2.6) addEventSource
I'm currently trying to test out FullCalendar
(version 2.2.6) addEventSource
$('button').click(function() {
$("#calendar").fullCalendar('removeEventSource', cal_events_1);
$("#calendar").fullCalendar('addEventSource', cal_events_2);
});
但我总是收到这个错误:
but I'm always getting this error:
Uncaught TypeError: Cannot read property 'hasTime' of undefined
这两个源都是硬编码的,用任何一个源加载日历都会成功加载事件,所以没有日期是不正确的。
Both sources are hard coded and loading the calendar with either source loads the events successfully, so no date is incorrect.
var cal_events_1 = [
{
events: [
{
title: 'event 1',
start: '2015-01-04',
color: 'tomato'
},
{
title: 'event 2',
start: '2015-01-09'
}],
color: '#55B2DA',
textColor: '#3c3c3c'
},
{
events: [
{
title: 'event 3',
start: '2015-01-06'
},
{
title: 'event 4',
start: '2015-01-07'
}],
color: 'rgb(255, 162, 71)',
textColor: '#3c3c3c'
},
{
events: [
{
title: 'event 5',
start: '2015-01-09'
},
{
title: 'event 6',
start: '2015-01-12'
}],
color: 'rgb(91, 228, 118)',
textColor: '#3c3c3c'
}];
var cal_events_2 = [
{
events: [
{
title: 'event 1',
start: '2015-01-04',
color: 'tomato'
},
{
title: 'event 2',
start: '2015-01-09'
},
{
title: 'event 3',
start: '2015-01-09'
}],
color: '#55B2DA',
textColor: '#3c3c3c'
},
{
events: [
{
title: 'event 4',
start: '2015-01-09'
},
{
title: 'event 5',
start: '2015-01-12'
}],
color: 'rgb(91, 228, 118)',
textColor: '#3c3c3c'
}];
加载日历:
Loading the calendar:
$("#calendar").fullCalendar({
eventSources: cal_events_1 // or cal_events_2
});
只有在调用 addEventSource
。我不确定有什么问题。
The error is displayed only when calling addEventSource
. I'm not sure what's wrong exactly.
更新
我知道 addEventSource
和 removeEventSource
提及使用数组作为数据源,但它看起来不起作用, cal_events_1
和 cal_events_2
都是对象数组。使用工作对象:
I know the documentation of addEventSource
and removeEventSource
mention using an array as a source but it looks like it does not work, cal_events_1
and cal_events_2
are both an array of objects. Using an object worked:
var my_events = {
events: [
{
title: 'event 1',
start: '2015-01-04',
color: 'tomato'
},
{
title: 'event 2',
start: '2015-01-09'
},
{
title: 'event 3',
start: '2015-01-09'
}
],
color: '#55B2DA',
textColor: '#3c3c3c'
};
$('button').click(function() {
$("#calendar").fullCalendar('removeEvents');
$("#calendar").fullCalendar('addEventSource', my_events);
});
推荐答案
您需要结束时间。
试试这个:
try this:
var my_events = {
events: [
{
title: 'event 1',
start: '2015-01-04',
end: '2015-01-06',
color: 'tomato'
},
]
};
这篇关于使用addEventSource时,FullCalendar v.2.2.6'hasTime'未定义错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!