php - How to populate the array of events in fullCalendar? -


i'm using fullcalendar plugin. want ask how populate events using loop.

in here, done statically enumerating in codes events:

var evt = [ {     title  : primaryassets[0],     start  : releasedates[0],  }, {     title  : primaryassets[1],     start  : releasedates[1], }]; 

fullcalendar:

 $('#calendar').fullcalendar({     header: {         left: 'prev,next today',         center: 'title',         right: 'month,agendaweek,agendaday'     },     editable: true,     weekmode: 'liquid',     weekends: true,      events: evt   }); 

this working if way. can see these events in calendar, want plot them dynamically using loop. here tried using loop displays last set of elements of array:

var primaryassets = <?php echo json_encode($primaryasset_array); ?>;  var releasedates = <?php echo json_encode($releasedate_array); ?>;   for(var = 0;i < count;i++) {     var primaryasset = primaryassets[i];     var release_date = releasedates[i];      // array of events     var getevent = [];       // inserting data database getevent array     var insertevents = {};         insertevents =         {             title: primaryasset,             start: release_date,         }     getevent.push(insertevents);  } 

fullcalendar:

$('#calendar').fullcalendar({ header: {     left: 'prev,next today',     center: 'title',     right: 'month,agendaweek,agendaday'     }, editable: false, weekends: true,  events: getevent  }); 

you overwriting getevent array on every iteration, result array contain 1 element last iteration,so move outside of loop, , should work fine, like:

var getevent = [];  for(var = 0;i < count;i++) {     var primaryasset = primaryassets[i];     var release_date = releasedates[i];      // array of events     //var getevent = [];  <-- move out of loop     // inserting data database getevent array     var insertevents = {};         insertevents =         {             title: primaryasset,             start: release_date,         }     getevent.push(insertevents);  } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -