I'm currently implementing Qtip2 tooltips thoughout my site, and they're working very well.
However, I need to set the position of the tooltip on a per-element basis. For this I've setup a couple of data
attributes like this:
<img src="/images/help-icon.png"
class="tooltip"
title="Lorem ipsum dolor sit amet consectetur adipiscing elit"
data-tooltip-my-position="right center"
data-tooltip-target-position="left center" />
I have tried using a function to get the data attribute, however it appears that the my
and at
properties do not accept a function, as this simply places the tooltip in the bottom right/top left which appears to be the default positioning.
$(this).find('.tooltip').qtip({
show: {
event: 'mouseenter click'
},
position: {
my: function() {
return $(this).data('tooltip-my-position'); // doesn't work
},
at: function() {
return $(this).data('tooltip-target-position'); // doesn't work
}
}
});
I have looked through the documentation, but there appears to be no guidance on programmatically setting positioning properties on or after initialisation.
Does anyone know if what I'm trying to do is possible, and if so, how?
$(this).data('tooltip-my-position');
– Stockstill$(this)
is out of scope. – Ial