I want a tooltip for an element (#hastitle) inside another element (#hover). The latter stops event propagation and does something on mouseover/mouseout.
html:
<div id="hover">
<div id="hastitle" title="bar">fu</div>
</div>
js:
$('#hover').on('mouseover mouseout', function (e) {
e.stopPropagation();
$(this)[e.type == 'mouseover' ? 'addClass' : 'removeClass']('hover');
});
$(document).tooltip({
tooltipClass: 'tip'
});
Why does the tooltip not work?
Also for a solution: I'm not sure whether I want to call e.stopPropagation()
on mouseover/mouseout for the element with the tooltip (#hover) yet.
So a solution that works for both cases would be very much appreciated.
Since the widget is initialized on
document
, the widget's event listeners will be attached to it. If we prevent event propagation it won't reach the handlers attached withdocument
.Simply allowing the event propagation seems to fix the issue for me.
Updated Fiddle
If you must prevent event from propagating further
#hover
, You can initialize the widget on it rather thandocument
: