我实现了一个正常工作的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
脚本,我的日历会正确显示,但是用英文显示...
你知道我为什么会收到这个错误吗?
答案 0 :(得分:1)
看起来你的loadScript函数是通过ajax或其他东西延迟加载脚本的。如果是这样,它将是异步的,并且当.fullCalendar方法运行时,locale-all.js脚本可能还没有完全加载,因此可能是区域设置代码不可用。
尝试使用<script>
标记正常声明脚本
答案 1 :(得分:1)
我知道这是一篇旧帖子,但供以后参考:
我刚刚发现这个函数在fullCalendar的v3中从“Lang”重命名为“Locale”。
https://fullcalendar.io/docs/v3/lang
如果您遇到有关 v3+ 的兼容性问题,可以尝试将函数 x.fullCalendar.datepickerLocale
更改为 x.fullCalendar.datepickerLang
,反之亦然
对我有用所以希望它对其他人有用