I am trying to feed the events section of FullCalendar with a JSON string from a cfc. The cfc is returning data, but I cannot get the data to return in the format needed for this plugin. The calendar is not responding to the events.
What do I need to do in setting up my cfc to return the proper format.
The JSON I am getting looks like this.
[["id: 237","title: Robert Byrd - First Appt.","start: 2011-05-24 11:00:00.0","allDay: false"],["id: 238","title: Margie Hambro - First Appt.","start: 2011-05-14 08:00:00.0","allDay: false"],["id: 302","title: Judy Nichols - First Appt.","start: 2011-05-17 15:50:00.0","allDay: false"],["id: 303","title: Ben Parker - First Appt.","start: 2011-05-23 10:15:00.0","allDay: false"],["id: 304","title: Robert Lentz - First Appt.","start: 2011-05-24 11:25:00.0","allDay: false"]]
<cffunction name="getLeadAppointments" access="remote" returnformat="json" returntype="any">
<cfargument name="start" type="any" required="true" default="">
<cfargument name="end" type="any" required="true" default="">
<!--- Get data --->
<cfquery name="data" datasource="#VARIABLES.dsn#">
SELECT LS.LeadSched_ID AS id,
LTRIM(COALESCE (CM.Contact_FName, '') + ' ' + COALESCE (CM.Contact_LName, '') + ' - ' + LD.DevType_Desc) AS event,
LS.LeadSched_TargetDate AS Start,
LS.LeadSched_ActualDate
FROM ...
Where convert(varchar(25), LS.LeadSched_TargetDate) BETWEEN #dateAdd("s", ARGUMENTS.start, "01/01/1970")# AND #dateAdd("s", ARGUMENTS.end, "01/01/1970")#
</cfquery>
<cfsilent>
<cfset calEvents = ArrayNew(2)>
<cfoutput query="data">
<cfset calEvents[#currentRow#][1] = 'id: #data.id#'>
<cfset calEvents[#currentRow#][2] = 'title: #data.event#'>
<cfset calEvents[#currentRow#][3] = 'start: #data.start#'>
<cfset calEvents[#currentRow#][4] = 'allDay: false'>
</cfoutput>
<cfset calData = SerializeJSON(data)>
</cfsilent>
<cfreturn calEvents>
</cffunction>
This is a guess, but I strongly suspect that your client code wants something that looks more like this:
Note that the entries in the outer array are changed here from arrays of strings (as you have) into objects, and that your original strings have been split into two (excepting the boolean property at the end, “allDay”, which is given the JSON native boolean
false).