kylestetz / CLNDR

:calendar: a jQuery calendar plugin that uses HTML templates
http://kylestetz.github.io/CLNDR/
MIT License
2.83k stars 446 forks source link

Show Tommorow Events #262

Closed yashilanka closed 8 years ago

yashilanka commented 8 years ago

Hi I Follow the answer that you gave for the "Current Day Events only" #109 question and I use that to get tomorrow events but it doesn't work as expected. I want to know is my implementation work or Did I missed something or is there a better way to get tomorrow events . this is the code I use


doneRendering: function() {
                // make a moment object representing today
                var target = moment();
                var tommorow = target.add(1,'days');
                var eventsTommorow =[];

                    if(this.options.multiDayEvents) {

                        eventsTommorow = $.makeArray( $(this.options.events).filter( function() {
                            // filter the dates down to the ones that match.
                            return ( ( tommorow.isSame(this._clndrStartDateObject, 'day') || tommorow.isAfter(this._clndrStartDateObject, 'day') ) &&
                            ( tommorow.isSame(this._clndrEndDateObject, 'day') || tommorow.isBefore(this._clndrEndDateObject, 'day') ) );
                        }) );

                    } else {
                        eventsTommorow = $.makeArray( $(this.options.events).filter( function() {
                            // filter the dates down to the ones that match.
                            return this._clndrDateObject.format('YYYY-MM-DD') == dateString;
                        }) );
                    }

                    if(eventsTommorow.length) {
                        console.log(eventsTommorow.length);
                        var newNum = eventsTommorow.length < 10 ? "0" + eventsTommorow.length : eventsTommorow.length;
                        return $('.td-emp-count.tdTommorow').text(newNum);
                    }
                }
            },

above code is the direct implementation that you solved "Current Day Events", I try to use that to get tomorrow events and counts, also I follow moment documentation and follow their isSameorBefore and isSameorAfter validation. but it also didn't work as expected.

also when i try to get event count using length. it shows me some wired result eg:

when the date is same day == show count as a 1 when the startDate and endDate are both same == show as a 1 when the startDate 24 and endDay is 25 it didn't show the correct count related to today event length.

this is the dataset if you want to try.

var events = [
            {
                date: '2016-05-10',
                title: 'Persian Kitten Auction'
            },
            {
                date: '2016-05-30',
                title: 'Cat Frisbee'
            },
            {
                date: '2016-05-30',
                title: 'Kitten Demonstration'
            },
            {
                date: '2016-06-07',
                title: 'Small Cat Photo Session'
            },
            {
                startDate: '2016-05-30',
                endDate: '2016-05-30',
                title: 'Monday to Friday Event'
            }, {
                startDate: '2016-05-30',
                endDate: '2016-06-31',
                title: 'Another Long Event'
            }, {
                startDate: '2016-05-31',
                endDate: '2016-06-01',
                title: 'Another Long Event'
            }
        ];

so can you give me a little hint or reference about how to implement this code.

Thank you

mikegioia commented 8 years ago

Hi @yashilanka, unfortunately we're keeping the Github issues to bug reports and browser inconsistencies only. I'm not entirely sure the cause of the problem you're having, but issues here need to identify a bug/problem, provide steps to reproduce the bug, and then provide the full config and events array to reproduce the error.

At first glance it doesn't appear that you're experiencing a bug, and you would most certainly have better luck at Stack Overflow.

yashilanka commented 8 years ago

ok thank you for the feedback, and one last question, how to get today only event list and count. is there a native method. I want to show them in a separate div. is this can do?. also is this information available in callback events.

mikegioia commented 8 years ago

I would say to just please read through the extensive documentation on the main page. What you're trying to do is not natively supported (i.e. there's no getTodaysEvents() API method) but what you have access to is a) your original events array, and b) the events objects in the template. Since CLNDR is based on a template, you could add the day's events to the DOM somehow in your template, or you could make a separate function to some getTodaysEvents that you have outside of CLNDR, but that still works with the events you originally passed into CLNDR (some common array of events).