How can I make the Bootstrap tooltip only appear when clicked inside a Vue Component and disappear when hovered over?

I am having a challenge with Bootstrap ToolTip in my Vue component. I only want the notice to show when the button is clicked, not on hover as it currently behaves. I attempted using jQuery within the Vue component without success. Can someone please advise on how to display the Bootstrap tooltip only on click?

const linkButton = {
  props: ["url"],
  data() {
    return {
      toolTipTitle: "Link Copied",
      currentUrl: this.url,
    };
  },
  methods: {
    copy: function () {
      var copyText = document.getElementById("myInput");
      // copyText.value = window.location.href
      copyText.select();
      copyText.setSelectionRange(0, 99999);
      document.execCommand("copy");
      console.log(copyText.value);
    },
    toolTipClicked: function () {
      this.copy();
      console.log("Tool Tip Clicked");
    },
  },
  template: /*html*/ `
    <a @click.prevent="toolTipClicked"  class="ml-4" href="#" id="tooltipLink" data-toggle="tooltip" :title="toolTipTitle">  
        <svg width="21" height="21" viewBox="0 0 21 21" fill="none" 
        xmlns="http://www.w3.org/2000/svg"> ... </svg>
    </a>
    <input type="text" style="position: absolute; left: -1000px; top: -1000px" :value="currentUrl" id="myInput">
    `,
};


Answer №1

Here's a solution for you to consider:

mounted() {
    $(document).ready(function () {
        $("#tooltipLink").tooltip({
            trigger: "click",
        });
    });
}

Answer №2

For more details: To ensure the tooltip vanishes on its own, I've implemented this approach:

tooltipLink.addEventListener("click", () => {
      setTimeout(() => {
        $("#tooltipLink").tooltip("hide");
      }, 1500);
    }); 

Hopefully, this solution will benefit others encountering the same issue

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

What is the best way to ensure an element reaches its full height limit without triggering the need for page scrolling?

Can you help me with a dialog box issue I am facing? $(document).ready(function() { $('.ui.modal').modal('show'); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <link hr ...

Is it possible to combine two conditions using CSS?

Hello, I have a question about CSS. In my navigation bar, I have 3 links with different styles: #p1 { font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 45px; font-weight: bolder; color: #999999; text-dec ...

What is the best way to iterate through an array in Vue using only half the number of iterations as the total number of items?

My data is stored in an array: [ { type: select, options: [foo, bar], label: foo, required: true }, { type: text, options: [], label: bar, required: false }, { type: checkbox, options: [], lab ...

The Angular Sortable Containment feature ensures that items cannot be dropped outside of

I am experiencing an issue with a horizontal sortable Angular list where the containment option is not functioning properly, causing the dragged item to not be dropped. Take a look at the sortable list below without a containment option - you may notice t ...

Implementing Dynamic Weight-based Pricing with CodeIgniter and AJAX

My shopping cart website utilizes ajax and Codeigniter to add products without reloading the page. Originally, I displayed a single net weight for each product. However, I recently switched to multiple net weights for the same product. Unfortunately, I am ...

What is the best way to deduct pixels from numbers using JavaScript?

Currently, I am attempting to adjust the height of the footer based on the height of another div element. My approach involves utilizing the .css("height") function. However, I am encountering difficulty as the function does not seem to return the value i ...

How does the rest operator in Javascript work when dealing with a different array input?

The following code snippet shows a function that uses Insertion Sort to sort an array of heights. The values being passed in are 4, 1, 9, 14, 6, and 8, and the sorted order should be 1, 4, 6, 8, 9, 14. var heightChecker = function(heights) { var sorte ...

When my contact form is viewed on mobile, an unexpected margin appears

On my main page, I have a contact form positioned on top of an image slider that appears like this: https://i.sstatic.net/aGnj1.png The contact form is nested inside the slider's div as shown below: <div class="img-slide"> <div c ...

Having trouble getting the jQuery autocomplete feature to function properly?

On my page, there is a button labeled "Add a Skill." Clicking on this button should trigger the display of an input box where you can enter your skill, another input box for your skill level, and a horizontal slider to select the skill level. In my databa ...

Vue3 Event Handling - Attempt to access an undefined property while rendering the component

Just starting out with Vue and JavaScript, but making progress! Currently working on a Vue Main App that includes a sub-component for a form (specifically to calculate the difference between 2 values). I want the form values to reset to their initial sta ...

Is there a risk of overloading the server and browser by making constant AJAX calls at regular intervals?

I am in the process of creating a website that requires notifications. I want to use AJAX to continuously check for updates in my database where notifications are stored at regular intervals. My concern is, with multiple users all accessing the AJAX call ...

Removing numerous key/value pairs from an object in real-time

Suppose I have an array of objects and I want to exclude certain keys/values. Instead of using the traditional delete method to remove one key/value pair, is there a way to specify which pairs I want to keep and remove all others? For example, in this ar ...

Encountered a buildkite error stating that the plugins file is either missing or invalid, resulting in a failure to locate the module 'xlsx' when executing a cypress test. Strangely

Encountering an issue while running my Cypress test on Buildkite. Here's the error message: Status: Downloaded newer image for cypress/included:6.1.0 [2022-01-31T10:32:13Z] Your pluginsFile is set to /e2e/cypress/plugins/index.js, but either the fil ...

Reduce whitespace when resizing

Is there a way to adjust the content to fill in the margin space when the browser is resized smaller? http://jsfiddle.net/denWG/62/ Html: <div class="jp-sleek jp-jplayer jp-audio"> <div class="jp-gui"> <div class="jp-controls jp-ico ...

Using MySQL with asynchronous promises

I'm currently delving into the world of promises. Here is a snippet of my code: checkEmailUsername = function(email, username) { return new Promise(function(resolve, reject) { var query; query = "SELECT * FROM users WHERE email = ? O ...

React - Issues with passing props correctly from mapped array to child component

I am currently working on a dashboard component that showcases rendered previews and code for HTML snippets. Within this dashboard component, I am utilizing the .map method to iterate through an array of snippets. Each snippet will have a pre-existing dele ...

Why isn't my Vue.js3 table being updated after using axios asynchronously?

After conducting my research, it appears that I have followed all the correct steps. However, I am unable to identify why my table is not updating. Initially, I create a new company and proceed to the overview, but nothing is being displayed. While checki ...

Update your MySQL database with ease by leveraging the power of AJAX through a dropdown menu

Can you provide guidance on updating a MySQL database using a dropdown menu and Ajax without reloading the entire webpage? I am facing issues with implementing the code, even after referring to various tutorials. Below is a snippet of my PHP script within ...

What is the best way to determine which option is most suitable: types, classes, or function types in TypeScript for

Currently, I am developing a small todo command line utility with a straightforward program structure. The main file is responsible for parsing the command line arguments and executing actions such as adding or deleting tasks based on the input provided. E ...

What is the best method to remove the x and up/down arrow components of an input date field?

My main objective is to have the orange triangle display in the box, but I'm unsure if CSS or another method is needed to remove the two elements on the left side of the triangle. Is there a way to achieve this? Currently, I am using the input type d ...