question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

is it possible to add a click event handler to the tooltip options ?

See original GitHub issue

i know that we already have the option of custom html, but consider this example.

  • we have a loop that will render a table with columns “keys, values, ops”
  • now for each cell of the keys column, we show a tooltip with some info
  • but we also want to allow the user to interact with that tooltip so we could do something like
v-tippy="{ position : 'right',  arrow: true, interactive: true, clickEvent: doSomething(data) }"

and inside the doSomething()

doSomething(data) {
 // data is basicly the 'data-original-title' tippy has auto-resolved for us
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:30 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
KABBOUCHIcommented, Nov 9, 2017

@ctf0 sorry for the delay, please check the code bellow

1- in content.vue edit tr: use data-html and store the current tr key value.

 <tr v-for="(mainV, mainK, mainI) in selectedFileDataClone" :key="mainI">
                        :title="getKey(mainK)"
                        v-tippy="{ position : 'right',  arrow: true, interactive: true }"
                        data-html="#tippyWithClickEvent"
                        @mouseover="onMouseOver(getKey(mainK))"

2- add to content.vue: reusable html template for tippy

<div id="tippyWithClickEvent" style="visibility: hidden">
    <a    class="click-me"
            :data-title="mouseoverKeyValue"
            :data-some-key="'cache value for later use!'">
                {{ mouseoverKeyValue }}
    </a>
</div>

3- add this method to content.vue

onMouseOver(val) {
    this.mouseoverKeyValue = val;
}

4- add this function to content.vue

mounted() {
    $(document).on("click", ".click-me", function () { // triggered when you click on the tooltip
        console.log($(this).data('title'))
    });
}

5- add data key/value to ops.js

 mouseoverKeyValue : ''
1reaction
ctf0commented, Aug 23, 2018

another way incase someone was after the same thing but easier than the docs

  • the title can return an html markup not just plain string, so instead of the extra template you can
<td v-tippy="{interactive: true}"
    :title="getTTC(Some-dynamic-value)">
</td>

// ...
methods: {
    getTTC(val) {
        return `<span style="cursor: pointer" class="c2c">${val}</span>`
    },
},
mounted() {
   // any events you want to hook into
    document.addEventListener('click', (e) => {
        let item = e.target

        if (item.classList.contains('c2c')) {
            // do something
        }
    })
},
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using click event handler prevents tooltips from displaying on ...
If you just specify click event then the chart will not respond to all other events like mousemove events. Try this: events: ['click',...
Read more >
Controlling tooltips & pop-up menus with components in React
1. Open the tooltip ; isOpen and ; style states to show/hide and position the tooltip component respectively. Also, it is required to...
Read more >
toggling series by clicking on tooltip label - Highcharts
You can make an addEventListener on the element of rendered label by Highcharts SVG Renderer and fire desired function on click event.
Read more >
Tooltips · Bootstrap v5.0
Elements with the disabled attribute aren't interactive, meaning users cannot focus, hover, or click them to trigger a tooltip (or popover). As a...
Read more >
Event and Action - Concepts - Handbook - Apache ECharts
Users can trigger corresponding events by their operation. The developer can handle the callback function by listening to these events, such as jump...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found