My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
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
Status:  Done
Owner:  ----
Closed:  Aug 2010


Sign in to add a comment
 
Reported by bram.van...@gmail.com, Jul 14, 2010
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
im pretty sure the problem here is really that your server-side script is returning false/null/undefined, and instead should be returning an empty list []
Status: Done
Aug 25, 2010
Project Member #2 adamrs...@gmail.com
 Issue 569  has been merged into this issue.
Aug 25, 2010
#3 bram.van...@gmail.com
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
#4 milderhl...@gmail.com
This post just helped me out, too. Thank you.
Sign in to add a comment

Powered by Google Project Hosting