Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
348 views
in Technique[技术] by (71.8m points)

fullcalendar incorrect event end date after eventResize

After resize an event, it returns an incorrect end date.. I don't understand why..

I'm using this code:

$('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,basicWeek,basicDay'
    },
    defaultDate: '2014-11-07',
    editable: true,

    eventDrop: function(event){
        event.start._i = event.start.format();
    },
    eventResize: function(event) {
        event.end._i = event.end.format();
    },

    eventLimit: true, // allow "more" link when too many events
    events: [{
        id: 'All Day Event',
        title: 'All Day Event',
        start: '2014-11-03'
    }, {
        id: 'popo',
        title: 'popo',
        start: '2014-11-04T10:30:00',
        end:   '2014-11-05T12:30:00',
        description: 'This is a cool event'
    }, {
        id: 'popo2',
        title: 'popo2',
        //url: 'http://google.com/',
        start: '2014-11-06'
    }]
});

If I simply move the event (drag & drop) it works fine and returns correctly the start date,

but if I resize the event, it returns an incorrect end date,
and also the start date becomes incorrect..

DEMO

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I've create a Plunker where you can see how the update is made.

It's important that, when you modify an event, the object you are modifying is the object that comes from fullCalendar('clientEvents');

Something like this will fail:

    myEvent = {
        id: 1, title : "myTitle", start: moment()
    }
    .fullCalendar('renderEvent', myEvent );
    mySlot.myTitle = "anotherTitle";
    .fullCalendar('updateEvent', myEvent );

But this will work:

    myEvent = {
        id: 1, title : "myTitle", start: moment()
    }
    .fullCalendar('renderEvent', myEvent );
    myFCEvent = .fullCalendar('clientEvents', 1);
    myFCEvent.title = "Another title";
    .fullCalendar('updateEvent', myFCEvent);

Demo Plunker


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...