Popover inside a table does not work

Asked

Viewed 430 times

2

I’m trying to put a Popover inside a row of a table that’s dynamically assembled according to the data coming from the database. I tested out of the table and it worked, but inside the table row no.

my Js is like this

 $(document).ready(function(){
            $('[data-toggle="popover"]').popover();   
        });

my html is like this

<tbody ng-repeat="dis in distritos ">
                    <tr>
                      <td>{{dis.idDistrito}}</td>
                      <td>{{dis.nome}}</td>
                      <td>{{dis.codigoDne}}</td>    
                     <td><a href="#" data-toggle="popover" title="Popover Header" data-content="Some content inside the popover">Toggle popover</a>

                    </td>
                    </tr>                       

  • Check the console if you are returning error, but I believe it is the lack of jQuery ... <script src="https://code.jquery.com/jquery.min.js"></script>

  • I tested out the <td> and it worked

  • It may be possible that there is some conflict going on, something like, see on the console, because I tested it here and it works.

1 answer

0


The problem is only in the note, your jQuery is not firing the Popover.

Add an attribute trigger at the <a> inside <td>:

<a href="#" data-toggle="popover" title="teste" data-trigger="hover" data-content="Some content inside the popover">Toggle popover</a>

And make a slight change to the event, deciding to add the Popover at the time of the event:

$(document).ready(function(){
    $('[data-toggle="popover"').on('mouseover',function(){
        $(this).popover();   
    })
});

Functional example in fiddle: https://jsfiddle.net/AnthraxisBR/nerpsqt7/2/

NOTE: include jQuery always before bootstrap js file.

  • I don’t think that’s it, because he said he put it out of the td and it worked

  • That’s right, he doesn’t have Rigger, no matter how much he asks Popover, he won’t shoot.

  • See here that I tested on jsbin in the case here, that is the same as his has to click to appear. So the question is not clear.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.