0

I hope you can help me out with a little problem. Right now I am working a little Listing-App project with Django. I have created my main HTML File for it and have a small table, where Django loads a list of movies inside, those movies have a Title that is a link and if you hover over this link a popover (from bootstrap 4) shows up with a small preview image from the movie. Now the problem is that the Popover is not always 100% centered. Most of the time the popover looks like this:

correct

But then again, sometimes (like 2 out of 7 movies) it looks like this:

incorrect

The weird thing is that this mostly happens when you hover for the first time over the link AND it doesn't occur all the time, sometimes it also occurs after you hovered like 2-3 times over it. I looked for a lot of solutions, but can't find any help. My Code is below:

{% extends "consilium/base.html" %}

{% block body %}
<table class="table">
<thead>
    <tr>
        <th></th>
        <th colspan="2">My Movielist</th>
        <th>
    </tr>
    <tr>
        <th></th>
        <th>TITLE</th>
        <th>GENRE</th>
        <th>RELEASE DATE</th>
        <th>DIRECTOR</th>
        <th>RUNTIME</th>
        <th>STATUS</th>
        <th>IMDB</th>
    <tr>
</thead>
</tbody>
{% if latest_movie_list %}
    {% for movie in latest_movie_list %}
    <tr>
        <td></td>
        <td>
            <a href="#" data-toggle="popover" data-placement="bottom" data-content='<img class="title-image" src="{{movie.image.url}}"/>'>{{ movie.title }}</a>
        </td>
        <td>{{ movie.get_genre_display}}</td>
        <td>{{ movie.date}}</td>
        <td>{{ movie.director}}</td>
        <td>{{ movie.runtime}} min</td>
        <td>{{ movie.get_status_display}}</td>
        <td>{{ movie.imdb}}</td>
    </tr>
    {% endfor %}
{% else %}
    <tr>
        <td>No Movies are available.</td>
    </tr>
{% endif %}
</tbody>
 </table>
{% endblock %}

Javascript:

 $(function () {
   $('[data-toggle="popover"]').popover({
html: true,
trigger: "hover",
container: 'body',
   })
 })

Also the class "title-image" in the data-content img tag has a width of 100%.

I hope someone can come up with a solution for this. It's not a tragic bug, but it would be nice to know how to fix it :)

Thanks to everyone who tries to help me!

NakedPython
  • 920
  • 2
  • 7
  • 27
  • Can you give us a live example? – Serg Chernata Mar 01 '17 at 18:32
  • What's your data look like? For instance, could it be there are many spaces after "Gone Girl" and not "Interstellar"? – Patrick Beeson Mar 01 '17 at 23:54
  • @SergChernata I'd love to, but this project is running on the Django Development Server and I don't know yet how to bring this live for other people to check out, I'm still new to the whole Django/Python topic and this is the first App I've ever did. Sorry :/ – NakedPython Mar 02 '17 at 08:22
  • @PatrickBeeson Nope, they don't have any spaces, its just the title names and noting more – NakedPython Mar 02 '17 at 08:23
  • Well I came up with a solution, it's no solution to the bug, but I just changed the direction from where the poster pop up (now they show up on the left side), looks definitely better, but that bug is still nagging me, would be interesting to know how to solve it or at least what causes it. – NakedPython Mar 02 '17 at 08:26
  • I am seeing the exact same thing. The popover center point is aligned with the right side of my anchor rather than the center of my anchor. – Greg Veres Sep 30 '17 at 05:28

0 Answers0