I need it to work when I click on a because I have a fixed sized div with only a single line of text in it like this:
<div style="width:200px; height:200px; background-color:yellow"
class="mytooltip"
title="Dismissible popover"
data-toggle="popover"
data-trigger="focus"
data-placement="auto right"
data-content="Click anywhere in the document to close this popover">
<a href="#">click me</a>
</div>
this is what I've tried:
// 1st method
$(document).ready(function(){
$('.mytooltip').click(function(e) {
alert('clicked'); // this alert is fired
$(this).popover(); // this doesn't
});
});
and I also found the method below but instead of triggering the popover on click, the popover shows on hover.. so I'm guessing this method doesn't care about the properties on the element and requires the popover parameters to be declared in the script but I haven't found any references about this..
// 2nd method
$('body').tooltip({
selector: '.mytooltip',
trigger: 'focus',
});
here's the jsfiddle of my latest attempt
EDIT:
- I mistakenly wrote 'tooltip' when I meant 'popover' in this question.
- it turns out that the 2nd method does take the data-properties into consideration.. (I didn't test it enough).
- but it still only triggers the popover when I click on the link. it won't show the popover when I click on the
div
area. - added a jsfiddle link to further clarify my question