【发布时间】:2017-01-19 16:27:14
【问题描述】:
我实现了一个 fullCalendar,它工作正常,但是一旦我想更改语言环境,就会出现以下错误:
Uncaught TypeError: e.fullCalendar.datepickerLocale is not a function
这里是配置fullCalendar的JS代码:
loadScript("js/plugin/fullcalendar/locale-all.js", "");
fullviewcalendar = $('#calendar').fullCalendar({
header: hdr,
editable: true,
droppable: true, // this allows things to be dropped onto the calendar !!!
locale: 'fr',
drop: function (date, allDay) { // this function is called when something is dropped
// retrieve the dropped element's stored Event Object
var originalEventObject = $(this).data('eventObject');
// we need to copy it, so that multiple events don't have a reference to the same object
var copiedEventObject = $.extend({}, originalEventObject);
// assign it the date that was reported
copiedEventObject.start = date;
copiedEventObject.allDay = allDay;
// render the event on the calendar
$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
// is the "remove after drop" checkbox checked?
if ($('#drop-remove').is(':checked')) {
// if so, remove the element from the "Draggable Events" list
$(this).remove();
}
},
select: function (start, end, allDay) {
var title = prompt('Event Title:');
if (title) {
calendar.fullCalendar('renderEvent', {
title: title,
start: start,
end: end,
allDay: allDay
}, true // make the event "stick"
);
}
calendar.fullCalendar('unselect');
}
});
我正在使用jquery 1.12.4、jqueryui 1.12.1 和fullCalendar 3.1.0、moment 2.17.1。
如果我没有加载local-all.js 脚本,我的日历会正确显示,但是是英文的...
你知道我为什么会收到这个错误吗?
【问题讨论】:
-
fullcalendar.io/support "最新版本的 FullCalendar 兼容:... jQuery 2.0.0+ Moment 2.9.0+" 我建议您将 jQuery 版本更新为受支持的版本,然后重试
-
我尝试使用 jquery 3.1.1 但仍然是同样的错误....
-
好吧,无论如何使用受支持的版本仍然值得。我又想到一件事。什么是 loadScript 函数?它是否通过 ajax 或其他方式延迟加载脚本?因为如果是这样,它将是异步的,并且可能在
.fullCalendar方法运行时 locale-all.js 脚本尚未完全加载完毕,因此可能语言环境代码不可用。尝试使用<script>标签正常声明脚本,看看是否有帮助 -
是的,你是对的,似乎我的脚本在调用 .fullCalendar 之前没有完全加载。通过使用简单的
-
好消息。我一直想知道为什么人们会延迟加载脚本,除非他们在移动应用程序中遇到严重的带宽问题或其他问题。它只是引入了另一个潜在的故障点。无论如何,我已将其添加为完整性的答案,因此,如果您能够接受和/或投票,我将不胜感激 - 谢谢
标签: javascript jquery fullcalendar momentjs