I am trying to create events in my full calendar dynamically.
I have:
$('#calendar').fullCalendar({ viewRender: function (view) { var h; if (view.name == "month") { h = NaN; } else { h = 2500; // high enough to avoid scrollbars } $('#calendar').fullCalendar('option', 'contentHeight', h); }, lang: 'fr', events: [ { title: '8 présents', start: data[0] }, { title: '8 excusés', start: data[1] }, { title: '8 excusés', start: '2015-01-08' }, { title: '8 présents', start: '2015-01-08' }, ], dayClick: function (date, jsEvent, view) { window.location.replace(Routing.generate('dateChoisie', {date: date.format()})); } })
I have var data, which is an array containing all the dates of the events. I want to insert this into events the same way as I inserted data [0], data [1], etc., but dynamically for all dates.
I tried to do for :
events: [ for (var i = 0, max = data.Lenght; i < max; i++) { { title: '8 présents', start: data[i] }, } { title: '8 excusés', start: data[1] }, { title: '8 excusés', start: '2015-01-08' }, { title: '8 présents', start: '2015-01-08' }, ],
But it does not work inside the list.
Does anyone know how I can do this?