First, here is the code that works:
$(function() {
$('#warning-binder-element').tooltip({
items: '.warning',
tooltipClass: 'warning-tooltip',
content: function () {
return $(this).prev('.warning-toast').html();
},
position: {
my: "right bottom",
at: "right top-10"
}
});
$('#info-binder-element').tooltip({
items: '.info',
tooltipClass: 'info-tooltip',
content: function () {
return $(this).closest('.doo-hicky').next('.info-toast').html();
},
position: {
my: "left bottom",
at: "left+10 top-10"
}
});
});
A few notes on the above:
- The selector for
.tooltip()
is not the item you want to have a tooltip pop up on, it is an element on the page that the tooltip object and its associated events are bound to.
- If you attempt to bind two tooltips to the same object, only the last one will persist so binding both to
$(document)
will not work (which is why I have bound the two different tooltip objects to two different elements on the page).
- you can bind the tooltip object to the item that will get the tooltip, but if you use a class selector, this may lead to ill effects.