Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sarathiscookie's avatar

How can add bootstrap tooltip inside Vue Js

I have a page for listing data from table using VueJs and Laravel. Listing data is successful. Delete and edit function is going on. For that purpose I have added two<span> (glyphicon-pencil), <span> (glyphicon-trash). If both <span> are outside the <template> tooltip shows, otherwise it doesn't works. Do you know how bootstrap tooltip works inside Vue Js. Thanks.

page.blade.php

<template id="tasks-template">
       <table class="table table-responsive table-bordered table-hover">
            <thead>
                   <tr>
                   <th>#</th>
                   <th>Id</th>
                   <th>Religion</th>
                   <th>Action</th>
                   <th>Created</th>
                   <td>Status</td>
               </tr>
           </thead>

      <tbody>
             <tr v-for="(index, task) in list">
             <td><input type="checkbox" id="checkbox" aria-label="checkbox" value="checkbox"></td>
             <td>@{{ index + 1 }}</td>
            <td>@{{ task.religion | capitalize }}</td>
           <td v-if="task.status == 'publish'">
                     <span class="glyphicon glyphicon-ok"></span>
           </td>
           <td v-else>
                     <span class="glyphicon glyphicon-remove"></span>
           </td>
           <td>@{{ task.created_at }}</td>
           <td>
               <span class="glyphicon glyphicon-pencil" aria-hidden="true" data-toggle="tooltip" data-placement="left" title="Edit"></span> 
               <span class="glyphicon glyphicon-trash" aria-hidden="true" data-toggle="tooltip" data-placement="right" title="Delete"></span>
           </td>
         </tr>
       </tbody>
        </table>
        </template>

        <tasks></tasks> 
@push('scripts')
    <script src="/js/script.js"></script>
@endpush 

scripts.js

$(function () {
    $('[data-toggle="tooltip"]').tooltip()
})


Vue.component('tasks', {

    template: '#tasks-template',

    data: function(){
        return{
            list: []
        };
    },

    created: function(){
        this.fetchTaskList();
    },

    methods: {
        fetchTaskList: function(){
            this.$http.get('/backend/religion/data', function(tasks){
                this.$set('list', tasks);
            });
        }
    }

});

new Vue({
   el: 'body'
});
0 likes
4 replies
EventFellows's avatar

Aparently it does not - at least I have not been able to make it work either. But there is a vue-awesome packages that now also included tooltips.

1 like
EmilMoe's avatar

Check out Keen-UI there's a Vue tooltip in that package

1 like
waynegibson's avatar

This will load the tooltip at the next tick with ES6.

 ready() {
        this.$nextTick(() => {
            $('[data-toggle="tooltip"]').tooltip()
        });
    },

Standard way.

 ready: function()  {
        this.$nextTick(function () {
            $('[data-toggle="tooltip"]').tooltip()
        });
    },
4 likes

Please or to participate in this conversation.