2

The problem description is in the title - the tooltip reappears when I close the modal dialog.

<script type="text/javascript">
    $(function () {
        $('[data-tooltip="tooltip"]').tooltip();
    });
</script>

<button type="button" class="btn btn-default" data-toggle="modal" data-target="#divModal" data-tooltip="tooltip" title="Tooltip!">
    <span class="glyphicon glyphicon-globe"></span>
</button>

see it happening here : http://jsfiddle.net/2gdrL6sf/

2 Answers 2

11

The problem is that the button is gaining focus when the modal is closed. To get around the tooltip showing again after the modal is closed you could restrict the tooltips trigger to a hover like so:

$(function () {
    $('[data-tooltip="tooltip"]').tooltip({
        trigger: 'hover'
    });
});

I forked your JSFiddle and have a working demo you can check out.

Hope that helps!

Sign up to request clarification or add additional context in comments.

3 Comments

Great! It seems to be working. I'm curious, is it possible to not focus the button at all on modal close?
I'm sure it is possible to not focus the button, but you'd have to track down what is causing the focus. There are modal events for showing and hiding you can hook into that may help with that. You can check the docs for available events.
All right, thanks :) I believe I am not a veteran enough in javascript to inspect a framework's code..!
1

In the button click handler, add a blur call to remove focus.

$('#myButton').click(function() {
    $(this).blur();
    $('#myDialog').dialog('open');
});

Buttons need to have focus and display a tooltip when not clicked so that assistive technologies can be effective. Somebody that's unable to use a mouse might need to tab between buttons. Setting the tooltip to only trigger on hover removes that capability.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.