1
votes

I'm trying to use FullCalendar v2.4.0 (with jQuery 1.10.2 and moment.js 2.1) in order to display events that are stored in a database. I'm using json to send events to FullCalendar.

I have some problems of duplicated events in the 'agendaWeek' view. Everything is working properly for the other views ('month', 'basicWeek', 'basicDay', 'agendaDay').

As i read on stackoverflow, I tried to remove the event source, to remove events,... but i'm still facing the problem.

Here's how the code looks like :

$('#calendar').fullCalendar({
    header: {
        left: 'prev,next,today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
    defaultDate: '<?=date("Y-m-d")?>',
    defaultView: 'agendaDay',
    timeFormat: 'HH:mm',
    displayEventEnd: true,
    events: {
        url: '/events_getlist_json.php',
        type: 'GET',
        cache: false,
        error: function() {
            alert('there was an error while fetching events!');
        },
        success: function(data) {
            $(data).each(function(index) {
                console.log( index + ": " + data[index].start );
            })
        }
    }
});

$(document).ready(function() {
    setTimeout(function(){
        $('#calendar').fullCalendar('render');
    }, 100);
});

The console log returns 2 events : "0: 2015-08-24T11:00:00" and "1: 2015-08-26T12:30:00" but i can see 4 of them on the calendar.

If you have any idea why duplicates happen in 'agendaWeek' view only, and how to remove them, it would be really nice to help. Thank you in advance.

edit : added version of the 3 scripts

1
What happens if you get rid of the setTimeout? It's the only thing I see that looks like a possible source of problems.DanielST
if i get rid of it, the calendar doesn't render : i'll just have the 'prev', 'next', 'today', 'month', 'week', and 'day' buttons displaying. And i'll get no console log at all.Daaaaa
hmm. Stick the whole fullcalendar init code into that setTimeout box, then. See if the problem still exists.DanielST
by doing so, the calendar renders, but the duplication on the 'agendaWeek' view still exists.Daaaaa
Yeah, unmodified latest FC. Regarding moment.js, it was 2.1, I updated moment.js to 2.10.6 and now it's working as it should. Thanks a lot for your time and your help @slicedtoad. I spent more than 20 hours trying to fix this, you're my savior !Daaaaa

1 Answers

2
votes

This was worked out in the comment between the OP and I.

Fullcalendar 2.4.0 conflicts with momentjs 2.1 causing duplicate events to appear in the agendaWeek view. Upgrade to the latest momentsjs to fix the issue.