3

I am trying to throw a tooltip when the end user clicks an event on the Full Calendar. It isn't throwing any errors or any information at all and i cant seem to get it to work. I haven't worked much with fullcalendar am i missing a plugin to get this working or is there a bug in my code? Im trying to mimic this Demo

import React from "react";
import ReactDOM from "react-dom";

import "./styles.css";

import FullCalendar from "@fullcalendar/react";
import dayGridPlugin from "@fullcalendar/daygrid";
import interactionPlugin from "@fullcalendar/interaction";
import Popper from "react-popper";
import Tooltip from "tooltip.js";

import "@fullcalendar/core/main.css";
import "@fullcalendar/daygrid/main.css";

let totalEarning = 156.75;

class ChildPortal extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      events: [
        { title: "Clean Bedroom", date: "2019-11-12" },
        {
          title: "Vaccume Room",
          date: "2019-11-13",
          color: "green",
          textColor: "white"
        },
        {
          title: "Vaccume Room along with dads room",
          date: "2019-11-13",
          color: "green",
          textColor: "white"
        }
      ]
    };
  }

  eventRender(info) {
    var tooltip = new Tooltip(info.el, {
      title: info.event.extendedProps.title,
      placement: "top",
      trigger: "click",
      container: "body"
    });
  }

  render() {
    return (
      <div>
        <div className="row">
          <div className="col-lg-12">
            <div className="text-center m-t-lg m-b-lg">
              <h1>
                Total Earnings:{" "}
                <span className="text-navy">${totalEarning}</span>
              </h1>
            </div>
          </div>
        </div>
        <div className="row">
          <div className="ibox">
            <div className="ibox-content">
              <FullCalendar
                defaultView="dayGridMonth"
                plugins={[dayGridPlugin, interactionPlugin]}
                events={this.state.events}
                eventRender={this.eventRender}
                schedulerLicenseKey="GPL-My-Project-Is-Open-Source"
              />
            </div>
          </div>
        </div>
      </div>
    );
  }
}

const rootElement = document.getElementById("root");
ReactDOM.render(<ChildPortal />, rootElement);

Code sandbox: Code Sandbox

Charles L.
  • 1,844
  • 2
  • 34
  • 56
  • It looks like you haven't included any CSS for the tooltip. It doesn't come with any of its own. If you go to the CodePen link from the fullCalendar demo you referenced, and open up the "CSS" part of the CodePen, you'll see some sample CSS you can use. – ADyson Nov 13 '19 at 17:09
  • @ADyson Add the CSS and it still didnt fix the issue – Charles L. Nov 13 '19 at 17:13
  • Looks like you also forgot to include popper.js (it must be included before tooltip.js, which depends on it) – ADyson Nov 13 '19 at 17:20
  • @ADyson still didnt do the trick :/ – Charles L. Nov 13 '19 at 17:23
  • I'm not sure react-popper is the correct thing to use. tooltip.js won't know anything about React. Try using the plain popper.js instead. – ADyson Nov 13 '19 at 17:40
  • @ADyson Still no dice i used popper.js instead – Charles L. Nov 13 '19 at 18:13
  • Not sure then. I'm not a React expert. To me it looks like you've got everything you need. Perhaps something else is interfering with it, although I can't see what. Maybe someone with React experience will be able to tell you what's up, sorry. – ADyson Nov 13 '19 at 22:16

0 Answers0