On my site I have some buttons. When a user clicks the button, a modal opens. When a user hovers the button, a tooltip is shown.
Is use this code:
<button type="button" rel="tooltip" title="Tooltip content" class="btn btn-sm btn-default" data-toggle="modal" data-target="#DeleteUserModal"> <span class="glyphicon glyphicon-remove"></span> </button> <div>modal</div> <script> $(document).ready(function(){ $('[rel="tooltip"]').tooltip(); }); </script>
This works, but the only problem is that the tooltip stays visible after the button is clicked, and the modal is shown. As soon as the modal is closed, the tooltip is hidden again.
How to prevent this? I only want the tooltip to be shown on hover, and not all the time when the related modal is visible.
The span element will contain a tooltip div with a little html (image and link). Tooltip should be opened when clicked on the span element and closed when clicked outside of it or outside of the tooltip.
How to position the tooltip - auto | top | bottom | left | right. When auto is specified, it will dynamically reorient the tooltip. When a function is used to determine the placement, it is called with the tooltip DOM node as its first argument and the triggering element DOM node as its second.
Fixed it by using.
$(document).ready(function(){ $('[rel=tooltip]').tooltip({ trigger: "hover" }); });
The problem was that focus stays on the button when the modal is open. Changing the trigger to hover solves the problem.
For your whole project hide tooltip
$(document).ready(function(){ $('[data-toggle="tooltip"]').click(function () { $('[data-toggle="tooltip"]').tooltip("hide"); }); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With