| Issue 555: | Fetching events with json error when there's no data. | |
| 2 people starred this issue and may be notified of changes. | Back to list |
Hi
I use an url to fetch my events and I pass them on via json. However, when there are no events, the code would use to error and cause problems for the "loading" function.
The error I got was on line 403 in fullcalendar.js:
for (var i=0; i<a.length; i++) {
I solved the problem by rapping the code block in an if(a != null) {}.
Code changed:
Line 400 - 412:
reportEvents = function(a) {
if (prevViewName == view.name && +prevDate == +date && // protects from fast switching
$.inArray(src, eventSources) != -1) { // makes sure source hasn't been removed
for (var i=0; i<a.length; i++) {
normalizeEvent(a[i], options);
a[i].source = src;
}
events = events.concat(a);
if (callback) {
callback(a);
}
}
},
became line 400 - 414
reportEvents = function(a) {
if(a != null) {
if (prevViewName == view.name && +prevDate == +date && // protects from fast switching
$.inArray(src, eventSources) != -1) { // makes sure source hasn't been removed
for (var i=0; i<a.length; i++) {
normalizeEvent(a[i], options);
a[i].source = src;
}
events = events.concat(a);
if (callback) {
callback(a);
}
}
}
},
Aug 25, 2010
Project Member
#1
adamrs...@gmail.com
Status:
Done
Aug 25, 2010
Issue 569 has been merged into this issue.
Aug 25, 2010
You are correct, this was the problem. Would it be possible to put this in the docs a little more clearly as it wasn't immediatly clear you should return an empty json list.
Mar 6, 2011
This post just helped me out, too. Thank you. |
|
| ► Sign in to add a comment |