I want to built a calendar that displays events which have are stored in a database. To do this I loop thru a set of records at the beginning of my script and build a string in a variable vEvents that ultimately contains this:
{
title: 'new appointment',
start: '12-OCT-2011 14:00'
},
{
title: 'next appointment',
start: '12-OCT-2011 15:00'
}
and so on. So each event is built by information that resides in the DB, the final number of events entries (between the two curly brackets) is unknown and can change dynamically for every call of the calendar.
I'm using a jQuery calendar plug-in (http://arshaw.com/fullcalendar) which builds the calendar using a jQuery call that goes like this:
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay',
},
editable: false,
height: 370,
firstDay: 1,
weekMode: 'liquid',
minTime: 8,
maxTime: 22,
weekends: false,
//and now on to the event creation
events: [
{
title: 'this is a standard event',
start: '11-OCT-2011 16:00'
},
{
title: ' yet another demonstration event',
start: '11-OCT-2011 17:00'
}]
});
What I would like to do is to replace anything between the edgy brackets [] in that call by the content of the previously built variable, so something like
//and now on to the event creation
events: [
$(vEvents) // or some other unknown syntax, or an evaluation function etc. that
// replaces the varibale with it's content at that place
]
I have not been able to get that replacement done, I tried the eval() function and some other approaches but then jQuery always complains about improper syntax. So is this possible to do overall and if positive how do I do this?