I am trying to do something very similar (if not the same) to what's been asked in the question here (the answer didn't work for me, it seems like the answerer/creator didn't understand the question).
My goal is to have two tippy tooltip instances on a single html element with different trigger options:
- one which will be triggered on
mouseenter
event (the default one, created using default tippy constructor without using the trigger option at all), and - one which will be triggered on
click
event (using trigger optionmanual
and calling the tippyshow()
function afterwards).
This is how I did it:
var myelement = document.getElementById('myelementid');
// Default way of creating tippy tooltips
tippy(myelement, {
content: 'Shown on hover.'
});
// Creating a tooltip which will be triggered manually/programmatically
var mytippy = tippy(myelement, {
content: 'Shown on click.',
trigger: 'manual'
});
myelement.addEventListener("click", function() {
mytippy.show(300);
setTimeout(function(){ mytippy.hide(300); }, 1500);
});
And for some reason it won't show the manually triggered tooltip on that element at all. I get this exception: Uncaught TypeError: Cannot read property 'show' of undefined at HTMLImageElement.<anonymous>
(refers to the tippy show()
function). But when I delete one of them (tippy instances), the other one works perfectly.