Notification on upcoming event date in FullCalendar

I've been thinking about the possibility of setting up a trigger to display something (like an alert, Qtip message, or any other notification) when today's date coincides with an event on my FullCalendar. Currently, I'm using XML from my Google calendar as the data source and would like to have notifications popping up for people's birthdays.

So far, I've implemented the following code snippet:

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!!!",
    show: {
       when: false,
       ready: true
    },
    hide: false,
    style: {
        classes: 'ui-tooltip-rounded',
       }
    });
}

The variable birthday stores each individual's birthdate that I define in the script, while today represents the current date. However, I realize that this method is not very dynamic since I need to set it up separately for each person.

Thank you in advance for your help.

Answer №1

When setting up your calendar object or function, be sure to include an eventAfterRender function. This function will only trigger when there is an event placed on the calendar. You can then retrieve the date, compare it to someone's birthday, and display a popup if it matches. I hope this helps! Here's a simple 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);
    // Use conditions to check if the year, month, and day match with the birthday
// If they do, you can call another function or execute the code for displaying the popup here

                }
            });
        });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can a Vue computed property return a promise value?

I have a specific computed property in my code that triggers an API request and retrieves the required data: async ingredients() { const url = "/api/ingredients"; const request = new Request(url, { method: "GET", credentials: "same-or ...

Troubleshooting: Issue with selecting items in jQuery Datatables

While attempting to construct a jQuery datatable using a data object, I encountered an issue. The table is displayed correctly, but the selection feature within the datatable is not functioning as intended. My expectation was that when a row is selected, i ...

Choosing Tags with Ajax in Select2

The JSON data below is fetched from /tags: [ { "id": "CSS", "text": "CSS" }, { "id": "HTML", "text": "HTML" }, { "id": "JavaScript", "text": "JavaScript" }, { "id": "jQuer ...

NodeJS - Bluebird: implementing a loop with a waiting mechanism for completion

Struggling with a seemingly simple task in my NodeJS and MongoDB project. I've included Bluebird for promises, but need some help. In my code, I have a basic for-loop that generates random names and pushes them into an array: const PlayerGenerator = ...

execute a function when an image is clicked using jQuery

How can I create an onclick event for the variable imageCatuaba? function setCatuaba(map) { var imageCatuaba = { url: 'images/catuskov.1.png', origin: new google.maps.Point(0, 0), anchor: new google.maps.Point(0, 32) }; I'm ...

Is there a way to apply styles to a checkbox's child element depending on the checkbox's state without relying on ternary operators within Styled Components?

I am currently working on styling this component using Styled Components, but I feel like my current approach is a bit of a hack. What would be the best practice for incorporating Styled Components to style this component effectively? If I were to use Pla ...

Is it possible to include multiple spyObjs within a beforeEach block?

In the process of testing an Angular 1 application using Jasmine, I have encountered a dilemma. My question is, can two spies be created for two different services within the same beforeEach statement? Currently, I have managed to make the first spy work ...

What is the process of transforming the content of a file into an array using JavaScript?

I have a file named "temperatures.txt" that contains the following text: 22, 21, 23 Is there a way to transfer the contents of this file into a JavaScript array? const weatherData = [22, 21, 23]; ...

Encountered an error stating "Cannot access property FindAll() of undefined" while working with a node/express JS app

Hey everyone, I'm encountering a problem with my express JS application and I'm not quite sure how to fix it. I'm working with an existing mySQL db and attempting to fetch items from my tbl_person table in the myDB database. As a newbie to t ...

What is the best way to update specific values in a react multiselect component?

Within my modal, I have a form where I can edit my model. One of the fields in this form is a multi-select tag field called "tags", which is an array of objects consisting of labels and values as illustrated below. To populate this tag field, I have a dum ...

"Troubleshooting: Child Component Not Reflecting Changes in UI Despite Using Angular

My child component is designed to display a table based on a list provided through @Input(). The data is fetched via http, but the UI (child component) does not update unless I hover over the screen. I've seen suggestions about implementing ngOnChange ...

Ensure that useEffect is triggered before the render process is finished, or consider using an alternate method to achieve

How can I trigger functions to execute when state changes without waiting for the render cycle to complete and without using up memory with useMemo or useCallback? Is there a way to achieve this similar to useEffect, but more direct and efficient? ...

Leveraging jQuery to detect an AJAX load that does not involve the use of jQuery's AJAX method

Hi all, I have a challenging issue that I'm struggling with in terms of jQuery/JavaScript. I am fetching data through standard AJAX without using any frameworks like jQuery. Now, the dilemma is that once the page has loaded, I need to implement a jQu ...

Is there a way to retrieve a website and make changes to its HTML and CSS?

I am interested in developing a platform where I can retrieve someone's website and present it using my own CSS. Additionally, I want to remove certain HTML tags from the retrieved content. Can you provide any guidance on how I can achieve this? What ...

Error: An unexpected identifier was encountered while executing my function

I've been trying to implement a function that I found online, but when I try to run it in the terminal, I keep getting this error: /home/simone/gekko/strategies/high.js:10 sma: function(name, price, points) ^^^ SyntaxError: Unexpected identifier I ...

What is the method for accessing HTML tag data within a script?

Looking for a way to extract a specific substring from a given string: var str = `<ul class="errorlist"><li>Enter a valid email address.</li></ul>`; Is there a method to extract the following substring? 'Enter a valid email ...

Complete Guide to Node.JS CRUD Delete Functionality

Currently, I am developing a node.js CRUD application that interacts with MongoDB. The main features of this app are allowing users to upload photos, edit details related to the photos, and delete them from the database. However, I am facing challenges i ...

Utilizing AngularJS to Transform String Formats

I need to transform multiple strings using AngularJS: String 1 Convert strings to 10 digits without the letter at the beginning A 908915-10 == 0090891510 B 6918546-05 == 0690891510 C 90002135-00 == 9000213500 String 2 Transform decimals to 10 d ...

Trigger a pop up using AJAX when successful

There is a button that, when clicked, triggers a pop up dialog box with the code below: <div class="button-wrap"><button data-dialog="somedialog" class="trigger">Open Dialog</button></div> The script responsible for activating the ...

Employing the next function in conjunction with an Express server during development

I currently have an express server handling my back-end operations. I am now in the process of transitioning my front-end to nextJS and would like to set up a proxy for my nextJS requests to access the port that my back-end is running on. Is it possible to ...