Search code examples
javascriptscheduleralloy-ui

Get events from AlloyUI Scheduler


Im trying to get the events from the Scheduler but cant seem to do so. By looking at their documentation I found that I needed to implement SchedulerEventSupport. I implemented it like this:

        var agendaView = new Y.SchedulerAgendaView();
        var dayView = new Y.SchedulerDayView();
        var eventRecorder = new Y.SchedulerEventRecorder();
        //global variable
        eventSupport = new Y.SchedulerEventSupport();
        var monthView = new Y.SchedulerMonthView();
        var weekView = new Y.SchedulerWeekView();

        schedule = new Y.Scheduler(
          {
            activeView: weekView,
            boundingBox: '#myScheduler',
            date: new Date(2013, 1, 4),
            eventRecorder: eventRecorder,
            items: events,
            render: true,
            eventSupport: eventSupport,
            views: [dayView, weekView, monthView, agendaView]
          }
        );

        function displayEvents(){
            console.log(eventSupport.getEvents());
        }

Everytime I run displayEvents() I get this error TypeError: Cannot read property 'sort' of undefined.

How Can I display the events saved in scheduler?


Solution

  • Use Scheduler.getEvents():

    function displayEvents(){
        console.log(schedule.getEvents());
    }