Ok, i just found i workaround to this, but if someone have a better and correct answer it will help a lot:
I put after the Vue instance this code:
$('#app').tooltip({
selector: '[data-toggle="tooltip"]'
});
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Here is my code:
<div v-if="form.errors.any()">
<span class="d-inline-block"
tabindex="0"
data-toggle="tooltip"
title="Fill the form correctly">
<button style="pointer-events: none;"
disabled="disabled"
class="btn btn-success">Create account</button>
</span>
</div>
To activate tooltips in bootstrap i had to use jQuery:
$('[data-toggle="tooltip"]').tooltip();
So i used Vue next tick to apply the code above in my root instance every cicle like so:
new Vue({
el: '#app',
mounted() {
this.$nextTick(function() {
$('[data-toggle="tooltip"]').tooltip();
});
}
});
The problem is that this doesnt work inside Vue directives like "if", it only works inside Vue components.
So, the question is simple, how can i use tooltips inside Vue if directives?
The HTML code above the tooltip is rendered only if the vue-if is true, so the tooltip doesnt work, but if i put the tooltip code outside the if, it works perfectly, am i missing something?
The reason your original solution didn't work is because v-if complete removes all events when false (the element is completely removed from the DOM, including its events).
The solution you found uses event delegation, which is "worse" performance wise, but normally not noticeable depending on the number of elements. However, it is really useful when dealing with dynamic elements.
If you want to stick with your original solution, you could use v-show instead of v-if to keep the element in the DOM (with all of its events), while being hidden/shown with CSS instead of removed/added completely.
Please or to participate in this conversation.