I want to have a powerTip
inside of another powerTip
.
The first tip (tip1
) displays fine but the second (tip2
) doesn't display at all. The CSS for tip2
works, in that the bottom border shows and all, but when you roll over it the powerTip
won't show.
<p>
Blah blah blah blah blah
<span data-powertiptarget="tip1">Blah</span>
and more blah blah blah.
</p>
<div id="tip1" class="tooltip-div">
<p>
Email: <a href="mailto:[email protected]">[email protected]</a><br/>
<span data-powertiptarget="tip2">Nomenclature</span>: Blah
</p>
</div>
<div id="tip2" class="tooltip-div">
Nomenclature: blah blah blah blah.
</div>
.tooltip {
border-bottom: 1px dashed #333333;
}
.tooltip-div {
display: none;
}
#powerTip {
text-align: left;
}
#powerTip a {
color: #FFFFFF;
}
#powerTip a:visited {
color: #F0F0F0;
}
#powerTip .tooltip {
border-bottom: 1px dashed #FFFFFF;
}
$('span[data-powertiptarget]').addClass('tooltip');
$('span[data-powertiptarget]').each( function() {
$(this).powerTip( {
placement: 'ne',
mouseOnToPopup: true,
smartPlacement: true
});
});
The reason why your tooltip doesn't show up is because the contents of each tooltip seem to get copied into a seperate div, and the events attached to it get lost in the process. You can see that quite well e.g. if you inspect the apearing tooltip via the chrome developer tools.
So, what you would need to do is create the powerTip2 instance inside the div#powerTip once the tooltip opens. Also you need unique ids for every opened tooltip.
Example on JsFiddle
Code:
$('span[data-powertiptarget]').addClass('tooltip');
createPowerTips($('span[data-powertiptarget]'),'powerTip');
function createPowerTips($elems, popupId) {
$elems.each( function() {
$(this).powerTip( {
popupId: popupId,
placement: 'ne',
mouseOnToPopup: true,
smartPlacement: true
}).on({
powerTipOpen: function() {
createPowerTips(
$('#powerTip').find('span[data-powertiptarget]'),
'powerTip2'
);
}
});
});
}
As you can see in the example, the nested tooltip has no CSS attached to it. So you'd have to copy all the #powerTip CSS over for #powerTip2
Clearly, the plugin has not been designed for such a use case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With