creating a hover effect for an event in fullcalendar.js

In my project, I am incorporating fullcalendar.js. The goal is to display a div when hovering over any event. Inside this div, there are three action buttons: edit, view, and delete. Let me share the relevant code snippets with you.

HTML

 <div id="calendar"/>

JavaScript/jQuery

<script>
      $('#calendar').fullCalendar({
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaWeek,agendaDay,listWeek'
                },
                eventMouseover: function(event, jsEvent, view) {
                    $template="<div class='hover-div clearfix' id='event_"+event.id+"'>"+
                        "<div class='display-inline-block'>"+
                        "<i class='fas fa-pencil-alt'></i>"+
                        "<a class='edit-calender common-font-properties'>Edit</a>"+
                        "</div>"+
                        "<div class='display-inline-block'>"+
                        "<i class='fas fa-eye'></i>"+
                        "<a class='edit-calender common-font-properties'>View</a>"+
                        "</div>"+
                        "<div class='display-inline-block'>"+
                        " <i class='fas fa-trash'></i>"+
                        " <a class='edit-calender common-font-properties'>Delete</a>"+
                        " </div>"+
                        "</div>";

                                       //$('.fc-content .fc-title', this).wrapAll("<div class='wrapall'><div>");
//                    $('.fc-content .wrapall', this).prepend($template);
                    $('.fc-content', this).prepend($template);
                },

                eventMouseout: function(event, jsEvent, view) {
                    //$('#event_'+event.id).remove();
                },
                navLinks: true, 
editable: true,
                eventLimit: true, 
events: [

                    {
                        id: 7,
                        title: 'Lunch',
                        start: '2018-08-12T12:00:00'
                    },
                    {
                        id: 8,
                        title: 'Meeting',
                        start: '2018-08-13T14:30:00'
                    },
                    {
                        id: 9,
                        title: 'Happy Hour',
                        start: '2018-08-14T17:30:00'
                    },
                    {
                        id: 10,
                        title: 'Dinner',
                        start: '2018-08-15T20:00:00'
                    },
                    {
                        id: 11,
                        title: 'Birthday Party',
                        start: '2018-08-16T07:00:00'
                    },
                    {
                        id: 12,
                        title: 'Click for Google',
                        url: 'http://google.com/',
                        start: '2018-03-28'
                  }
              ]
            });
  </script>

JSBIN

The issue at hand is that the hover div I've created seems to be positioned behind the main container, making it partially or completely hidden on smaller screens. Despite attempting various solutions like adjusting the z-index, the visibility of my div remains a challenge. Any suggestions or assistance would be greatly appreciated.

Answer №1

Your current markup won't allow the desired functionality to work as the child cannot have a higher z-index than the parent. You'll need to place your hover div outside of the calendar markup and position it accordingly.

While you could write the solution yourself, using a library would be the easiest way to achieve this.

Take a look at the Fullcalendar demo, which utilizes Bootstrap popover functionality. By inspecting the event tooltip in the dev tools, you'll see that the tooltip markup is added below the calendar. If you're not using Bootstrap, another option is qtip2, a jQuery plugin often used with FullCalendar.

Example utilizing qTip2:

$("#calendar").fullCalendar({
  defaultView: "basicWeek",
  defaultDate: "2018-04-07",
  resources: [
    { id: "a", title: "Room A" },
    { id: "b", title: "Room B", eventColor: "green" },
    { id: "c", title: "Room C", eventColor: "orange" },
    { id: "d", title: "Room D", eventColor: "red" }
  ],
  events: [
    {
      id: "1",
      resourceId: "a",
      start: "2018-04-06",
      end: "2018-04-08",
      title: "event 1"
    },
    // Additional event objects here...
  ],
  eventRender: function(event, element) {
    element.qtip({
      content: {
        title: { text: event.title },
        text:
          '<span class="title">Start: </span>' +
          $.fullCalendar.formatDate(event.start, "hh:mmtt") +
          '<br><span class="title">Description: </span>' +
          event.description
      },
      hide: {
        delay: 200,
        fixed: true
      },
      position: {
        target: "mouse",
        adjust: {
          mouse: false
        }
      }
    });
  }
});

CodePen showcasing a functional qTip2 demo.

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

The debate between client-side and server-side video encoding

My knowledge on this topic is quite limited and my Google search didn't provide any clear answers. While reading through this article, the author mentions: In most video workflows, there is usually a transcoding server or serverless cloud function ...

Optimizing the If operator in JavaScript to function efficiently without causing the page to reload

While delving into jQuery and attempting to create a slider, I encountered a problem. After the slider passed through the images for the second time, the first image would not appear. My approach involved using margin-left to move the images. $(document ...

A guide to displaying a countdown timer in an Angular application during the app's loading process

Displaying a loader that shows the time in seconds while loading an app is my goal. Here is the code snippet: HTML <body> <div class="app-loader"> <div class="loader-spinner"> <div class="loading-text"></div> ...

Learning how to use arrow functions with the `subscribe` function in

Can someone help clarify the use of arrow functions in TypeScript with an example from Angular 2's Observable subscribe method? Here's my question: I have code that is functional: this.readdataservice.getPost().subscribe( posts =&g ...

Discovering useful data like metadata and subject matter through the utilization of either a URL or the webpage itself alongside JQUery

Imagine you have a URL and you want to display information related to that URL on your webpage, similar to how Facebook or LinkedIn does. You input a URL and the website data is retrieved for display. I am working on an application using JQuery and HTML ...

Condition within ng-repeat consistently evaluating to true

I'm currently designing a table to display data from the Premier League. I'm attempting to utilize ng-if to determine if the home team emerged victorious, and if so, include a cell stating "Home team won" HTML <div ng-if="data.full_time_resu ...

In need of a collection of modules determined by a DefinePlugin constant

Currently, I am in the process of constructing a web application utilizing Webpack. However, I have encountered a challenge with a particular aspect of the design - hopefully someone in this forum has experience in similar tasks (or possesses enough knowle ...

Approach for checking duplicates or empty input fields through PHP, AJAX, and JavaScript

Looking for a solution to validate and check for duplicate values when listing, creating, or deleting products using a REST API. I tried using rowCount in the php file to check for duplicates but I feel there might be a better approach that I am missing. N ...

The class instances are not invoking the decorators

I'm experiencing issues with my decorators. It seems that the decorators are not being invoked on every instance of the class. While I understand that decorators are called during declaration time, I am wondering if there is a way to call them for eac ...

Unable to access API endpoint for retrieving items as described in the Express/React tutorial on Pluralsight

Currently, I am going through a tutorial on React, Express, and FLUX. Unfortunately, I have encountered a roadblock in the form of a CANNOT GET error when trying to access my API data. https://i.stack.imgur.com/RbUzf.png In the server file under Routes & ...

Is it possible to switch the background-image after a gif has finished loading?

I am currently using a GIF as a background image, but I would like it to show a static image until the GIF is fully loaded and ready to play. After reading several similar discussions, I understand that you can manipulate elements with JavaScript once the ...

TypeScript Error: Attempting to slice an undefined property - TypeError

In my Angular project, I have a csv file containing data that is imported along with the D3.js library: group,Nitrogen,normal,stress banana,12,1,13 poacee,6,6,33 sorgho,11,28,12 triticum,19,6,1 The TypeScript file includes code for displaying a stacked ba ...

Unable to use Office.context.mailbox.item.displayReplyAllForm with attachments on outlook.live.com as well as receiving internal server errors when using the Outlook API

When using office.js outlook add-ins, the displayReplyAllForm with attachments function is opening the reply form without attachments in outlook.live.com. However, it works perfectly fine in outlook.office.com. Is there any workaround for this issue? Off ...

Steps to activate the click function of a JQuery tab component

Having trouble triggering the click event on one of the elements in my JQuery tab. In a JQuery tab, clicking a link changes the content of a specified div to the contents of another div with an id specified within the '<a> </a>' tag o ...

creating interconnections between input fields by employing event listeners in JavaScript

I've been experimenting with binding multiple input fields to a span element using jQuery. Specifically, I have two input fields containing integer values and the sum of these values is displayed in a span element. I want the span element to update wh ...

Adding a unique element to other elements in jQuery/Javascript can be achieved even when the existing elements only have classes assigned to them

One interesting feature of a Wordpress theme is the ability for site administrators to create forms with descriptions for each field. These descriptions share a common class, 'description,' and look like this: <div class="field-head"><l ...

I'm encountering issues with this code for a dice game. It's strange that whenever I click the roll dice button, it disappears. Additionally, linking an .css sheet seems to cause the entire page to

I'm currently working with two separate codes: one for HTML and the other for JavaScript. I am facing an issue where the button keeps disappearing when I try to add any CSS styling to it. Even a basic CSS file seems to override everything else and lea ...

Incorporating ES6 (ECMAScript 2015) modules: bringing in index.js

As I explore the depths of the Internet, I find myself puzzled by the mysterious "index.js" module file. Through the use of babelJS + Node.js or Browserify/Webpack, I am able to effortlessly import an "index.js" module located within a "libs" directory wi ...

React fails to trigger a re-render despite updating the state following an API call

Recently, I started working with React and attempted to retrieve data from my API. However, changing the state does not trigger a re-render of the component. Inside the useEffect function in my component, I have code that fetches the API and then sets the ...

Upon refreshing the page, nested React routes may fail to display

When I navigate to the main routes and their nested routes, everything works fine. However, I encounter an issue specifically with the nested routes like /register. When I try to refresh the page, it comes up blank with no errors in the console. The main r ...