Bugfix in agenda.js (fixes #1041)