来自cfc文件的json feed不在FullCalendar中显示

时间:2014-11-14 15:51:44

标签: json events fullcalendar cfc

我正在尝试使用json将事件传递给FullCalendar,但它们没有显示。有谁知道我的json的结构是否有问题?

CFC文件:

<cfcomponent>
    <cfsetting showDebugOutput='No'>
    <cffunction access='remote' name='getEvents' >

        <cfset var events = [{'id'='10','title'='Urlaub','start'='2014-11-14 07:30:30','end'='2014-11-14 08:30:30'}]>

    <cfreturn serializeJSON(events)>

    </cffunction>
</cfcomponent>

CFM文件:

eventSources:
        [
            {
                url: 'events_for_calendar_test.cfc?method=getEvents',
                color: 'yellow',
                textColor: 'black'
            }
        ]

传递JSON Feed:

[{“start”:“2014-11-14 07:30:30”,“end”:“2014-11-14 08:30:30”,“id”:“10”,“title” : “Urlaub”}]

1 个答案:

答案 0 :(得分:1)

wddxpacket被coldfusion serializeJSON添加到json中。只需要为函数添加属性,以确保它只返回我需要的东西。

<cfcomponent>
<cfsetting showDebugOutput='No'>
<cffunction access='remote' name='getEvents' returnformat="JSON" returntype="String">
    <cfset var events = [{'id'='10','title'='Urlaub','start'='2014-11-14','end'='2014-11-14'}]>
    <cfreturn serializeJSON(events)>
</cffunction>