【问题标题】:fullcalendar locale Uncaught TypeError: e.fullCalendar.datepickerLocale is not a functionfullcalendar locale Uncaught TypeError: e.fullCalendar.datepickerLocale is not a function
【发布时间】: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.4jqueryui 1.12.1 和fullCalendar 3.1.0moment 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


【解决方案1】:

看起来您的 loadScript 函数正在通过 ajax 或其他方式延迟加载脚本。如果是这样,它将是异步的,并且可能在 .fullCalendar 方法运行时 locale-all.js 脚本尚未完全加载,因此可能语言环境代码不可用。

尝试使用<script> 标签正常声明脚本

【讨论】:

    【解决方案2】:

    我知道这是一篇旧帖子,但供将来参考:

    我刚刚发现这个函数在fullCalendar v3中从“Lang”改名为“Locale”。

    https://fullcalendar.io/docs/v3/lang

    如果您对 v3+ 有兼容性问题,可以尝试将函数 x.fullCalendar.datepickerLocale 更改为 x.fullCalendar.datepickerLang 或反之亦然

    为我工作,所以希望它对其他人也有效

    【讨论】:

      猜你喜欢
      • 2015-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-13
      • 2014-08-15
      • 2021-12-16
      • 2018-04-20
      • 2017-04-13
      相关资源
      最近更新 更多