Utilizing FullCalendar for showcasing comprehensive details

I'm a big fan of the fullcalendar plugin and all its amazing features. I want to enhance it by displaying more customized information for each event when in agendaWeek or agendaMonth view. Switching between views is easy, but I need help filtering out certain information.

eventRender: function(event, element,view) { 
    if(view.name!="month"){
       //my custom code goes here        
    }

Here's my dilemma: I'm currently working on a user activity tracking system where each day may consist of multiple activities that users need to complete. For instance, one day could have 3 activities scheduled at specific times - activity 1 starting at 9am, activity 2 at 11:30am, and activity 3 at 3pm. I want these activities to be displayed as one block spanning from 9am-3pm, with each individual activity marked individually. To differentiate between them, I plan to assign different background colors.

It's important to note that I only want to create one event to represent all these activities, similar to how meetings in real life have one overall meeting event with several agendas.

Answer №1

Review the code snippet available in this JSFiddle link, which demonstrates how to manipulate the DOM before and after rendering events.

<div style="border:solid 2px red;">
    <div id='calendar'></div>
</div>
<script>
$(document).ready(function() {

    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        defaultView: 'agendaDay',
        editable: true,
        events: [
        {
            id: 1,
            title: "Meeting",
            start: new Date(y, m, d, 9, 0),
            end: new Date(y, m, d, 15, 0),
            allDay: false}
        ],
        eventRender: function(event, element, view) {
            element.find('.fc-event-content').append('<div class="fc-sub-event">9am - 11:30am</div>');
            element.find('.fc-event-content').append('<div class="fc-sub-event">11:30am - 1pm</div>');
            element.find('.fc-event-content').append('<div class="fc-sub-event">1pm - 3pm</div>');
        },
        eventAfterRender: function(event, element, view) {
            var eleHgt = element.height()/3.5;
            $('.fc-sub-event').height(eleHgt);
        }
    });
});
</script>

Next, explore this alternative implementation by referring to the following code in the provided JSFiddle link. It showcases a method of formatting event data for a more generalized approach.

<div style="border:solid 2px red;">
    <div id='calendar'></div>
</div>
<script>
$(document).ready(function() {

    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        defaultView: 'agendaDay',
        editable: true,
        events: [
        {
            id: 1,
            title: '<div class="fc-event-title">Meeting</div><div class="fc-sub-event">9am - 11:30am</div><div class="fc-sub-event">11:30am - 1pm</div><div class="fc-sub-event">1pm - 3pm</div>',
            start: new Date(y, m, d, 9, 0),
            end: new Date(y, m, d, 15, 0),
            allDay: false}
        ],
        eventRender: function(event, element, view) {
            element.find('.fc-event-content').html(element.find('.fc-event-content').text());
        },
        eventAfterRender: function(event, element, view) {
            var eleHgt = element.height()/3.5;
            $('.fc-sub-event').height(eleHgt);
        }
    });
});
</script>

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 AJAX response is not functioning as expected

I've encountered an issue with my AJAX code for an online food store. Every time I run it, a pop-up message saying something went wrong appears instead of the expected output. I suspect there might be an error in either the connection handlers or the ...

Implementing a gradient effect on a specific image element within an HTML canvas with the help of jQuery

Currently, I'm working on an HTML canvas project where users can drop images onto the canvas. I am looking to implement a linear gradient effect specifically on the selected portion of the image. My goal is to allow users to use their mouse to select ...

Deciding Between Promises and Callbacks in Node.js

As I update my older Node.js code, I am also creating new modules to integrate with the existing code. One challenge I face is transitioning from using callbacks to utilizing ES6 promises more frequently. This has created a mixture of functions that return ...

"Enhance your HTML table by selecting and copying cell values with a simple click and CTRL +

I stumbled upon a fantastic script for highlighting HTML table rows and it's working perfectly: I decided to modify the onclick event to onmouseover and included additional code to select a cell by clicking on it. Now I can select, check which one is ...

Java REST service remains out of reach for JavaScript fetch call

Currently, I am in the process of learning about REST API. My goal is to make a call to a POST service implemented in Java from Javascript using fetch. However, I have encountered an issue where the request fails to reach the service whenever the @Produces ...

Tips on saving content that changes automatically

I am curious about the best way to store dynamically displayed HTML content. For example, when a certain element is clicked on a website, I want text to appear elsewhere on the page. One idea I had was to create a variable in a JavaScript/jQuery script to ...

Organizing outcome searches through ajax

I have a result table displayed on the left side https://i.stack.imgur.com/otaV4.png https://i.stack.imgur.com/pp9m0.png My goal is to transform it into the format shown on the right side of the table In a previous inquiry found here, @Clayton provided ...

What impact does the //g flag in Regex JavaScript have on the program's state?

I recently had a question that was answered, but I'm still trying to grasp why the regex behaves in a certain way. According to w3schools, it explains: g: Perform a global match (find all matches rather than stopping after the first match) Okay, ...

Basic jQuery Slideshow Counter

I'm having trouble implementing a text-based horizontal slider on my website that scrolls left and right with mouse control. I want to display the current index of each slide along with the total number of slides (e.g. 1/4) and update the index as use ...

Leveraging the Recyclability Aspect of a ReactJS Modal

Looking for a way to make a modal dynamic without duplicating too much code. Any suggestions on how to achieve this? I've managed to separate the state from the layout using render props. interface State { open: boolean; } interface InjectedMod ...

Events are not loading in FullCalendar

I've integrated FullCalendar into my asp.net MVC application. However, I'm facing an issue where the events are not loading properly when fetched through an ajax call. Below is the code I'm using. Can you help me identify the problem? <d ...

Issue with preventDefault not functioning correctly within a Bootstrap popover when trying to submit a

I am facing an issue with a bootstrap popover element containing a form. Even though I use preventDefault() when the form is submitted, it does not actually prevent the submit action. Interestingly, when I replace the popover with a modal, the functional ...

What could be causing the delay in $q.all(promises).then() not waiting for the promises to complete?

Currently, I am tasked with utilizing AngularJS 1.5.5. My task involves making calls to multiple Rest-Services and handling the results simultaneously. $scope.callWebservices = function(){ let promises = { first: callFirstWebservice(), ...

Building on the Vuejs3 and Vuex4 framework, create a conditional rendering feature that triggers upon

I have a unique setup where custom objects are used to hold child objects full of data. The child objects start with null values for all properties, allowing them to be filled with data from remote sources when referenced. This results in a lazy-loading sy ...

The Zustand store does not reflect changes when the URL is updated

I have a Zustand store connected to the URL. See the code snippet provided below. import { create } from "zustand"; import { persist, StateStorage, createJSONStorage } from "zustand/middleware"; const pathStorage: StateStorage = { ge ...

Unable to utilize jQuery library in AngularJS partial HTML files, despite being loaded in the index.html file

I have been working with a web template that utilizes jQuery image gallery and other elements. Now, I am looking to convert this template into an AngularJS structure. To do so, I have created partial HTML pages like slider.html or contact.html along with t ...

What are some best practices for implementing responsive design using CSS @media queries with makeStyles in React.js Material UI?

const useStyles = makeStyles(theme => ({ wrapper: { width: "300px" }, text: { width: "100%" }, button: { width: "100%", marginTop: theme.spacing(1) }, select: { width: "100%", marginTop: theme.spacing(1) } })); I ...

"Issue with Material-ui Autocomplete where the defaultValue does not function properly

The defaultValue was set to "Chairs" but it doesn't seem to be working as expected. Here is the code snippet: import React, { useState } from "react"; import TextField from "@mui/material/TextField"; import Autocomplete from "@mui/material/Autocomple ...

What is the best way to pass values between JSP Expression Language and Javascript?

I have a request object with the following content: List<Integer> list What is the best way to loop through this list using JavaScript? I am interested in obtaining the values of each element within the list. Note that these list values are not cu ...

Investigating the Netbeans PHP Xdebug Socket Exception while debugging Joomla

System Information PHP Version 5.4.0-1build1~ppa1~oneiric Xdebug v2.2.0rc1, Copyright (c) 2002-2012, by Derick Rethans Apache/2.2.20 (Ubuntu) While debugging a Joomla project, I encounter a Socket Exception error right before reaching the spot where the ...