I need to be able to create an event by clicking on a "Add new" button that's external to the calendar and for that I'm using createEvent() and this works fine in all views except TIMELINE, where it fails with:
this.activeView.createEvent is not a function
It looks like Scheduler doesn't have such functionality.
You can test this quickly in the example I linked to above if you insert the following at the end of the code editor:
and then click on the page's title. You should see an error when you're in Timeline view, and you should see the expected behaviour when you're in other views.
As you have noticed Scheduler does not offer the same API as Calendar. You could try calling createEvent() on a built in Calendar view instead of directly on Calendar when Scheduler is active. Or you could add a new event on the data layer.
Something like this (not fully working code) for the first scenario:
sorry to re-open this thread, we've developed a method which worked well until version 5.0.1.
With version 5.0.2, an error is shown.
The code we use to create an event is the following:
btn_add_new.addEventListener('click', function () {
if (calendar.activeView.isScheduler) {
calendar.modes.day.createEvent(calendar.date);
} else {
calendar.createEvent();
}
});
The error that is generated is:
calendar.module.js:19555 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'isRectangle')
at Scroller._callee5$ (calendar.module.js:19555:7)
at tryCatch (runtime.js:63:16)
at Generator.invoke [as _invoke] (runtime.js:294:1)
at Generator.next (runtime.js:119:1)
at asyncGeneratorStep (calendar.module.js:121790:11)
at _next (calendar.module.js:121790:11)
at calendar.module.js:121790:11
at new Promise (<anonymous>)
at Scroller.<anonymous> (calendar.module.js:121790:11)
at Scroller.scrollIntoView (calendar.module.js:19552:3)
Do you have any hints on what can we do to avoid this error?