FullCalendar 输入在 eventDataTransform 中未定义



我有这个带有完整日历的应用程序,除了事件数据转换之外的所有内容都可以正常工作。代码真的很大,所以我会发布相关部分

$(document).ready(function () {
    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay,basicDay',
        },
        allDaySlot: false,
        nextDayThreshold: '00:00:00',
        slotLabelFormat: 'h(:mm)a',
        views: {
            month: {
                //para que no se pueda arrastrar en la vista month
                droppable: false,
                timeFormat: 'h(:mm)a',
                showNonCurrentDates:true,
            },
            week: {
                timeFormat: 'h:mm:ss a'
            },
            day: {
                timeFormat: 'h:mm:ss a'
            },
            basicDay:{
                droppable: false,
            }
        },
        locale: getVarLocale(),
        editable: true,
        droppable: true,
        slotDuration: '00:15:00',
        eventDurationEditable:false,
        eventDragStart:function( event, jsEvent, ui, view ) {
            isDragging=true;
        },
        eventDragStop:function( event, jsEvent, ui, view ) {
            isDragging=false;
        },
        dayClick: function (date, jsEvent, view) {
            if(isValidDate(date)==false)
                return false;
            if (view.name === "month") {
                $('#calendar').fullCalendar('gotoDate', date);
                $('#calendar').fullCalendar('changeView', 'agendaDay');
            }
        },
        eventOverlap: function (stillEvent, movingEvent) {
if(stillEvent.start.isSame(movingEvent.end)||stillEvent.end.isSame(movingEvent.start)){
                return false;
            }
             if (movingEvent.type == tiposEventos.bloque){
                    if(isDragging==false)
                        performAlert(translationCal.noNestedBlock,'event');
                    return false;
             }
            if(movingEvent.overlaped==false){
                if (stillEvent.type!=tiposEventos.bloque){
                    if(isDragging==false)
                        performAlert(translationCal.noOverlapAllowed,'block');
                    return false;}
            }
            if(movingEvent.start.isBefore(stillEvent.start)){
                if(isDragging==false)
                    return false;
            }
            updateEvent(stillEvent, movingEvent,true);
            return true;
            function performAlert(msg,type){
                var alerted = localStorage.getItem(type) || '';
                if(alerted=='alerted')
                    return false;
                localStorage.setItem(type,'alerted');
                var e=Array();
                e.push(msg);
                addModalError('pm-modal-error',$translation.error, e);
            }
        },
        eventDataTransform:function(eventData){
              console.log(eventData);     
        },
        eventSources:[
            {
                events: function (start, end, timezone, callback) {
                    var events = [];
                    var options = {};
                    options.data = {};
                    options.data.start=start.format('YYYY-MM-DD');
                    options.data.end=end.format('YYYY-MM-DD');
                    options.type = 'text/json'
                    options.method = 'POST';
                    options.url = Routing.generate('publication_all');
                    options.errorcallback = function (error) {
                        console.log(error);
                    }
                    options.successcallback = function (data) {
                        var parseData = JSON.parse(data);
                        $(parseData).each(function () {
                            var startTime = this.startTime;
                            startTime = (((startTime.date).split(' ')[1]).split('.'))[0];
                            var startObj = moment(startTime, 'HH:mm:ss');
                            var startDate = (this.startDate.date).split(' ')[0];
                            var startDate = moment(startDate, 'YYYY-MM-DD HH:mm:ss').utcOffset(+0000);
                            startDate.set({
                                'hour': startObj.get('hour'),
                                'minute': startObj.get('minute'),
                                'second': startObj.get('second')
                            });
                            var endTime = this.endTime;
                            endTime = (((endTime.date).split(' ')[1]).split('.'))[0];
                            var endObj = moment(endTime, 'HH:mm:ss');
                            var endDate = (this.endDate.date).split(' ')[0];
                            endDate = moment(endDate, 'YYYY-MM-DD HH:mm:ss').utcOffset(+0000);
                            endDate.set({
                                'hour': endObj.get('hour'),
                                'minute': endObj.get('minute'),
                                'second': endObj.get('second')
                            });
                            if(isValidDate(startDate)==true){
                                events.push(
                                    {
                                        title: this.title, // use the element's text as the event title
                                        idRef: this.idRef,
                                        type: this.type,
                                        publicationId: this.idPub,
                                        color: setColors(this.type,this.idRef),
                                        overlaped: false,
                                        overlaps: false,
                                        parentBlock: this.parent,
                                        start: startDate,
                                        end: (startDate.diff(endDate)==0)?endDate.set({'second':endDate.get('second')+1}):endDate,
                                        stick: true,
                                        idRef: this.ref,
                                        direct:-1,
                                        allDay:false,
                                        durationEditable:(this.type==tiposEventos.bloque||this.type==tiposEventos.patron||this.type==tiposEventos.sennal)?true:false
                                    }
                                );
                            }
                        });
                        callback(events);
                    };
                ajaxAccess(options);
                }
            }
        ],
    });

});

问题是,一切正常,但事件数据转换总是抛出类型错误:输入未定义out._id = input._id ||(input.id === 未定义 ?'_fc' + 事件GUID++ : input.id ...

我检查了文档,并以正确的方式调用了该事件。我不知道问题是否与我的eventSource是一个ajax函数有关。

你的函数不返回任何内容。事件数据转换函数必须这样做。至少你可以测试:

console.log(eventData);
return eventData;

相关内容

  • 没有找到相关文章

最新更新