I need to display more text in the fullcalander. but the problem is i am getting data from the mySQL db as json data through ajax call. so i dont know the exact length of data which is coming. so i need to show the daily events in the fullcalendar dynamically in a loop. the following code i tried but i didnt got the output. can anyone help me. thanx in advance
var testJson = ['value1', 'value2'];
$('#full_calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
events: [
for(var i=0;i<2;i++){
{
title: ''+testJson [i],
start: new Date(y, m, 3)
}
} ]
});
2 things first:
when you want to know the exact length of the recived data…. why not send them within the JSON object?
e.g.
var test = {"data":[1,2,3,4,5],"size":5}the second way to get the lentgh is the length field. Every javascript object has a length field. In the example above test.data.length would return 5 (as test.size would do).
and i’m pretty sure you can’t run a iteration within a array declaration, so just build the array befor:
without jquery it would like this:
and then pass it to your function call