I have a test page with bootstrap 3 using tooltip to display a message to the user when the user mouses over an icon.
Clicking on the icon displays a modal and when the modal is closed, the tooltip remains displayed to the user because the focus is still applied to the icon.
The only way to remove the displayed tootip is when the user physically clicks somewhere on the form to remove the focus from the icon.
I have noticed that the display of the tooltip issue occurs on the tooltip examples page.
I have tried to use jquery to remove the focus when the user clicks on the icon, but this approach did not work as anticipated.
Here is my html code:
<a href="" id="id_page_help" data-target="#myModal" data-toggle="modal" rel="tooltip" class="no_decoration" title="Help">
<i class="icon-bulb icon_size18"></i>
</a>
Here is my jquery code:
<script>
$('#id_page_help').click(function () {
$('#id_page_help').blur();
//alert('xxxx'); //alert does display - code triggered.
});
</script>
I am hoping that someone can point out what I have done incorrectly or supply a way to remove the focus.
5
Answers
Try putting the script in
$(document).ready(function() {....});
Actually it is really an issue in twitter bootstrap.
And in your case you’ve to use modal-box events and jQuery‘s
blur
for handiling:focus
for thebutton
.Here’s the
jQuery
I’ve used:I’ve also created a JSFiddle.
Please have a look, that will do the trick for you.
I know it’s been a while since this question was asked, but for anyone having the same issue,
this can also be done by overriding the default ‘trigger’ for tooltips:
This will show all tooltips only when hovering over the target element as oposed to the default behaviour which is to trigger the tooltip on hover and focus on the target element.
try the below code instead of the above code