未定义不是 Fullcalendar js 上的函数

Undefined is not a function on Fullcalendar js

需要 fullcalendar.js 方面的帮助。当我在网络检查器上看到时,我发现了一个错误 "Undefined is not a function"。但我认为代码很好。 您可以查看此 fiddle https://jsfiddle.net/3kq85hx0/ 了解详细信息。

$(document).ready(function() {

    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    var calendar = $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'resourceDay,resourceWeek,resourceNextWeeks,resourceMonth'
        },
        defaultView: 'resourceWeek',
        firstDay: 1,    
        editable: true,
        selectable: true,
        minTime: 8,
        snapMinutes:10,
        weekNumbers: false,
        weekNumberTitle: 'Viikko ',
        refetchResources: true,
        maxTime:16,
        selectHelper: true,
        resources: 'json-resources.php',
        events: [       
            {
                title: 'Meeting from this day to this +4',
                start: new Date(y, m, d, 10, 30),
                end: new Date(y, m, d+4, 11, 00),
                resource: 'resource1'
            },  
            {
                title: 'Meeting last week',
                start: new Date(y, m, d-7, 10, 30),
                end: new Date(y, m, d-7, 12, 15),
                resource: 'resource1'
            },  
            {
                title: 'meeting tomorrow',
                start: new Date(y, m, d+1, 10, 30),
                end: new Date(y, m, d+1, 12, 00),
                resource: 'resource1'
            }   
        ],
        select: function(start, end, allDay, jsEvent, view, resource) {
            var title = prompt('event title:');

            if (title) {
                calendar.fullCalendar('renderEvent',
                    {
                        title: title,
                        start: start,
                        end: end,
                        allDay: allDay,
                        resource: resource.id
                    },
                    true // make the event "stick"
                );
            }
            calendar.fullCalendar('unselect');
        },
        resourceRender: function(resource, element, view) {
            // this is triggered when the resource is rendered, just like eventRender
        },
        eventDrop: function( event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view ) { 
            alert('event moved to '+event.start+' to '+event.resource);
        },
        eventResize: function( event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view ) { 
            alert('event was resized, new endtime: '+event.end);
        },
        eventClick: function ( event, jsEvent, view )  {
            alert('event '+event.title+' was left clicked');
        }
    });
});

谢谢。

"undefined is not a function" 来自自定义全日历脚本。具体在 6373:eventElement.draggable({.

这是因为 draggable 没有定义。 draggable 是 jqueryui 的一部分,所以我删除了您的 jquery ui 脚本并从 google's cdn.

添加了一个

fiddle 现在可以正常工作了。

此外,正如评论中所讨论的,您使用的是旧版本的 fullcalendar。而这个特殊的习俗 build 有一堆 issues.

首先,我不知道你的计划有多长,但 Adam Shaw 目前正在对 fullcalendar 进行官方 timeline 更新。你可能想看看这个。

到那时,还有this fork that is mostly up to date. You can read about it here。不知道能不能满足你的需求,你不妨看看。