FullCalendar - JSON源不起作用,但直接使用JSON数据 [英] FullCalendar - JSON source doesn't work but using the JSON data directly does

查看:106
本文介绍了FullCalendar - JSON源不起作用,但直接使用JSON数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的页面上正确设置了FullCalendar,并试图让它读取json源文件。



当我直接访问它时,我的json源代码工作正常通过网址,如果我复制屏幕上输出的数据,并将其直接放入FullCalendar事件,事件显示。



设置事件到我的网址json源只是不工作。我已经使用Firebugs NET面板来检查这个调用,它正确地定位了JSON源,并且获取了正确的数据,但是没有在日历中显示它。



我已经设置了ID,标题,全天(到真实)开始(unix和yyyy-mm-dd格式)和结束(尽管这是可选的)

任何想法?

 < script> 
$(document).ready(function(){
$('#calendar')。fullCalendar({
events:eventsjson//链接到我的symfony2项目中的控制器。直接访问给出正确的json输出
});
});
< / script>

json资源提供的数据:

 {id:1,title:Test Event,start:1331309234,allDay:true} 
pre>

将^^^直接插入到事件设置中并没有问题。 (时间戳是由php的time()函数产生的)解决方案

这个问题与PHP的自然行为不包括[]如果添加了第二个,则[]括号由PHP添加,并且FullCalendar插件正常工作。

p>

我相信这是FullCalendar的错,完全是诚实的,并且已经将它作为作者的一个bug。


I have FullCalendar setup up correctly on my page and I am trying to get it to read a json source.

My json source works fine when I access it directly via the url, and if I copy the data outputted on screen and put this directly into the FullCalendar events, the event shows up.

Setting the events to the url of my json source just doesnt work. I have used Firebugs NET panel to inspect the call, and it is correctly locating the JSON source, and is fetching the correct data, but simply not showing it on the calendar.

I have set id, title, allday (to true) start (both unix and yyyy-mm-dd format) and end (despite this being optional)

Any ideas?

<script>
$(document).ready(function() {
    $('#calendar').fullCalendar({
        events: "eventsjson" // links to a controller in my symfony2 project. accessing cirectly gives correct json output
    });
});
</script>

Data given by json source:

{"id":1,"title":"Test Event","start":1331309234,"allDay":true}

Inserting that ^^^ straight into the events setting work no problem. (the timestamp was generated by php's time() function)

解决方案

The issue is with PHP's natural behaviour to NOT include the [] brackets when there is only 1 entry in the JSON object.

If a second is added, the [] brackets are added by PHP and the FullCalendar plugin works correctly.

I believe this to be the fault of FullCalendar in all honesty, and have filed it as a bug with the author.

这篇关于FullCalendar - JSON源不起作用,但直接使用JSON数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆