Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tooltip + modal in button - bootstrap

<button type="button" class="btn" data-placement="bottom" rel="tooltip" title="Info" data-toggle="modal" data-target="#myModal"></button>

Got modal and tooltip in 1 button. After modal is being closed, tooltip is being shown. I don't want that. I'm trying to achieve with this code:

$('[rel="tooltip"]').tooltip('manual');
     if (!$('#myModal').is(':visible')) {
         $('[rel="tooltip"]').tooltip('hide');
     }

Whats wrong with this code?

like image 239
nehel Avatar asked Dec 03 '22 16:12

nehel


2 Answers

Triggering the tooltip that way holds the focus after the modal pops up, this code should work for you.

$(document).ready(function(){
    $('[rel="tooltip"]').tooltip({trigger: "hover"});
});
like image 159
Jason Avatar answered Dec 11 '22 17:12

Jason


actually this is not the best approach to achieve what you want you can do it in another way check this fiddle

just wrap your btn in a span which will trigger the modal

<span data-toggle="modal" data-target="#myModal">
    <button type="button" class="btn btn-primary" data-placement="bottom" title="Info" data-toggle="tooltip">Launch demo modal</button>
</span>
like image 30
Sherif Ahmed Avatar answered Dec 11 '22 15:12

Sherif Ahmed