Include toggle attribute in v-b-popover for touch functionalities

Currently, I am implementing v-b-popover on my website to handle both touch and mouse events. To achieve this, I have set the tag of v-b-popover as 'hover'. I am wondering if there is a way for me to toggle the popover (show and hide) for both touch and mouse events.

<b-col v-for="lesson in Lessons">
<b-button
 v-b-popover.hover.bottom="lesson.lessonName">
{{lesson.lessonName}}
</b-button>
</b-col>

Answer №1

By default, the tooltip's trigger includes touch on mobile along with hover. This means that if you only need touch events on mobile and hover on desktop, it should work without any modifications.

<b-button v-b-popover.hover="'Hello World!'">
  A tooltip will be displayed on hover on desktop, and on touch on mobile.
</b-button>

If you also want to support mouse clicks on desktop, an additional trigger is required. You can use either click or focus for this purpose.

<b-button v-b-popover.hover.click="'Hello World!'">
  A tooltip will appear on hover/click on desktop, and on click on mobile.
</b-button>

Answer №2

If you want to add a popover functionality to your buttons, you can use the directive v-b-popover.hover.focus.bottom. This allows your buttons to be triggered by either a click or hover event, making it compatible with both mobile devices and mouse interactions.

new Vue({
  el: '#app',
  mounted() {
    document.getElementsByTagName('body')[0].addEventListener('click', e => {
      this.$root.$emit('bv::hide::popover')
    });
  }
})
#app {
  margin: 2rem;
}
<link type="text/css" rel="stylesheet" href="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aeccddd1d7c6cbd9ffcfc8b499b39914ed3dfcce3ded699dbeffeffe2">[email protected]</a>/dist/css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="44262d372622202233260f33322b63393f273318262c10">[email protected]</a>/dist/bootstrap-vue.css" />

<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="63151713161401121615261e11430116192b171b03541b0d17134f5658441551191114531815181f">[email protected]</a>/dist/vue.min.js"></script>
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cdafa4aeaabbaaaabbdafefbe87848998bfada193adaba1bdcfa3afa7bba0aebbbca3afa788bacda1a6acb4aec8abafb5abbbeacdbdda93939429202e28268239353121">(bootstrap.v.j)</a>/dist/bootstrap-vue.min.js"></script>

<div id="app">
  <b-button v-b-popover.hover.focus.bottom="'Hello World!'" variant="info">Your Button</b-button>
</div>

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

Enabling the value to be set as true for radio buttons generated using v-for

Utilizing a v-for loop over an array of objects in graphicState, the rows of a table are dynamically generated. My goal is to implement a column of radio buttons that, when checked, will set graphicState[index].selected to true. I came across this insight ...

Introducing cutting-edge intellisense for Typescript Vue in VSCode, featuring automatic import functionality specifically designed for the

Currently, I am working on a small project using Typescript and Vue in VSCode. In my setup, I have TSLint, TSLint Vue, Vetur, and Prettier plugins installed. Unfortunately, I am facing an issue with the intellisense "auto import" feature. It does not seem ...

`Can v-model be used to update the key of an object within an array element?`

My form is designed to fetch questions from an API, and I am looking to collect answers in separate input fields for each question. To achieve this, I have set up a response array with a length greater than or equal to the number of questions, pre-filling ...

Utilize Vue.js methods to reverse the string within a paragraph using the appropriate function

Hello everyone, I've been attempting to implement a function to reverse a string within a paragraph text in vue.js. I've created a method called reverseword to reverse the words and added it to a card using :rule="reverseword()", but un ...

The b-table footer is not showing up on Bootstrap-vue

Currently, I am utilizing version "2.0.0-rc.11" of "bootstrap-vue", and I am facing an issue with the footer not displaying in the table. Despite referring to the documentation examples, I have been unsuccessful in resolving this problem. Here is My Code: ...

How can I float a square to the right in Bootstrap with a col-md-4 size but with a height restricted to only 200 px

Looking to add a small square on the page for users to search and purchase courses directly. The square should be 4 columns wide, follow Bootstrap4 grid template, and be around 200-300 px in length. It needs to remain visible as the user scrolls down the p ...

Managing Uploaded Files using Laravel and Vue.js

Currently, I am in the process of developing a Vue.js + Vuetify + Axios + Laravel framework for creating a dashboard. One of the functionalities I am working on is the user profile, which includes the ability for users to upload a profile picture and their ...

Concentrate on Selecting Multiple Cells in ag-Grid (Similar to Excel's Click and Drag Feature)

Is there a way to click and drag the mouse to adjust the size of the focus box around specific cells in ag-Grid? This feature is very handy in Excel and I was wondering if it is available in ag-Grid or if there is a workaround. Any insights would be apprec ...

Encountering a problem: The function _ctx.openNote is not recognized as a function when attempting to click on a note for viewing

I started with my notepad app from the ground up, which can be found on this link: Issues with data bind in vue.js and events The problem I encountered was that I couldn't click on the note from NoteList.vue to view the details. There seems to be a d ...

Separate modules in the Webpack.mix.js file don't produce any output files in the public folder

I've recently been tackling a Laravel project with an extensive webpack.mix.js file residing in the root directory, boasting nearly 5000 lines of code. In an effort to enhance organization and maintainability, I've opted to break it down into ind ...

Using Vuexfire to bind Firebase references with pagination and infinite scrolling

Query: How do I implement pagination (infinite scroll) for my bound Firestore VuexFire reference without re-querying previously fetched (and bound) data? Context: I am currently using VuexFire firestore binding to populate a timeline with the most upvoted ...

Using a .vue file in an HTML document: A step-by-step guide

After creating a hello.vue file, I am unsure how to actually use it in an HTML file. I have already set up webpack, <template> <p>Hello</p> <p>{{message}}</p> </template> <script> module.exports = { data: ...

Divide a single image into several smaller images and enable clickable links on each separate image, similar to an interactive image map

Challenge: I am faced with the task of splitting a large image (1920px x 1080px) into smaller 40px by 40px images to be displayed on a webpage. These smaller images should come together seamlessly to recreate the original full-size image, with 48 images a ...

The installation of webtorrent-hybrid failed due to the error message "node-pre-gyp: command not found"

I'm currently encountering an issue while attempting to install webtorrent-hybrid for developing an electron p2p application. Vue UI is the framework I am using to handle front-end development, and I have successfully created a new project utilizing v ...

Personalized Bootstrap 4.1 Toggle Animation

I have been attempting to implement a customized menu toggle on Bootstrap 4.0's Navbar menu, using the code provided by Codeply HERE. My goal is to apply the X toggle style to my website's bootstrap navbar. Below is the current setup I have imple ...

Is there a way for me to incorporate view charts into my JavaScript file with Vue.js?

I have a project with index.html, script.js, and style.js. I want to implement vue-echarts for a single page. How can I achieve this? <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail= ...

An interface display within a network router

My current project involves an authentication system and a backend dashboard. By default, the route displays the authentication component: { path: "/", name: "Authentication", component: Auth }, Once logged in, I am redirected to another Vue compon ...

What could be causing transition to not be recognized as an element in HTML?

<template> <header> <nav class="container"> <div class="branding"> <router-link class="header" :to="{name : 'Home'}">>FireBlogs</router-link> </div& ...

Update the Laravel public directory

I need to update the public folder to public_html, but encountering issues with commands and functions still referencing the old public directory. While using Laravel+Vue for a single page application, my usual practice of renaming the public folder to pu ...

Adding local JavaScript to a Vue component is a great way to enhance its functionality

I am currently working on integrating a homepage concept (Home.vue) into my project. The design is based on a template that I purchased, which includes CSS, HTML files, and custom JavaScript. While most of the CSS has been successfully imported, I am havin ...