Get all events in a month using onMonthChange()

Issue #19 resolved
Jakov A. created an issue

First of all, great calendar library. Simple and easy to install. But I'm having some problem when customizing it.

So, I'm trying to get all of the current events using onMonthChange() method. What I wanna do is to display the events of current month into a container (let me deal with that later).

Here is what I did so far, but didn't get any luck:

            function addLeadingZero(num) {
                ...
            }

            $(".responsive-calendar").responsiveCalendar({
                onMonthChange: function(events) {

                    var thisMonthEvent, key;
                    key = $(this).data('year')+'-'+addLeadingZero( $(this).data('month') );
                    thisMonthEvent = events[key];

                    console.log(thisMonthEvent.dayEvents[0].name); // didn't return anything
                },
                time: yyyy+'-'+mm,
                events: {
                "2014-07-27": {
                    "number": 1,
                    "dayEvents": [
                        {
                            "name": "Event 1 ",
                            "hour": "19:00"
                        }
                    ]},
                "2014-07-28": {
                    "number": 1,
                    "dayEvents": [
                        {
                          "name": "Event 2",
                          "hour": "08:00" 
                        }
                    ]}, 
            ...

Does anyone know how to get this?

Comments (3)

  1. Lukasz Kokoszkiewicz repo owner

    Hi Aiman,

    I've updated the documentation. In onMonthChange call-back you can use this to access entire responsiveCalendar object, events included.

    PS. I know it's a bit messy callbacks wise now and I promise I will fix it in v1.0 ;)

    Cheers, Lukasz

  2. Lukasz Kokoszkiewicz repo owner

    BTW. You don't have to use time property, when not set the calendar will set to current month.

  3. Log in to comment