开发者

FullCalendar alert on event date

开发者 https://www.devze.com 2023-04-08 08:46 出处:网络
my question is: Is it possible to trigger something (ie. alert, Qtip, whatever) when today\'s date is the date of an event in the FullCalendar? I am using the XML from my Google calendar as the source

my question is: Is it possible to trigger something (ie. alert, Qtip, whatever) when today's date is the date of an event in the FullCalendar? I am using the XML from my Google calendar as the source and would like something to pop up for people's birthdays.

I already have:

var difference = birthdate - today;
var days = Math.round(difference/(1000*60*60*24));

if (days == 0){
    $('#tabs').qtip({
    position: {
               my: 'bottom right',
               at: 'top left',
    },
    content: "It's someone's birthday!!!",
    sh开发者_如何学编程ow: {
       when: false,
       ready: true
    },
    hide: false,
    style: {
        classes: 'ui-tooltip-rounded',
       }
    });
}

Where birthday is the individuals birthdate (which I set as a var) and today is ,obviously, today's date. The problem I have is that this is not very dynamic as I will have to do this seperately for everyone.

Many thanks in advance.


When you create your calendar object/function you need to create a eventAfterRender function. This only fires when you have a function that has been placed on the calendar. Then you can read the date and compare it to ones birthday and display popup. I hope that is what your were looking for. I gave a little example.

    $(document).ready(function () {
            $('#calendar').fullCalendar({
                height: 600,
                width: 700,
                header: {
                    right: 'prev,next today',
                    center: 'title',
                    left: 'month,agendaWeek,agendaDay'
                },
                eventAfterRender: function (event, element, view) {
                    birthday = new Date('<somedate>');
                    year = new Date(event.start).getFullYear();
                    month = new Date(event.start).getMonth();
                    day = new Date(event.start).getDate();
                    alert(year + ' ' + month + ' ' + day);
    //do some if statement to see if the year matches then if the month, then the day. 
//if so then go to another function or just put the code here for the pop 

                }
            });
        });
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号