Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a way to put python (django) variables into jquery onmouseover popup?
    primarykey
    data
    text
    <p>I'm trying to create popups for my website when someone scrolls over an image. The problem is that I am trying to display different information about people when you scroll over their avatar, and I use a for loop to display all the people. When I use the following code, the correct avatar for each person is displayed, however the popup information is always the same for each person, and not the information specific to that person.</p> <pre><code>&lt;script&gt; $(function() { var moveLeft = 20; var moveDown = 10; $('a#trigger').hover(function(e) { $('div.pop-up').show(); //.css('top', e.pageY + moveDown) //.css('left', e.pageX + moveLeft) //.appendTo('body'); }, function() { $('div.pop-up').hide(); }); $('a#trigger').mousemove(function(e) { $("div.pop-up").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft); }); }); &lt;/script&gt; {% for person in people %} &lt;div id="container"&gt; &lt;a href="#" id="trigger"&gt;&lt;img src="{{ MEDIA_URL }}/{{ person.avatar }}" /&gt;&lt;/a&gt; &lt;div class="pop-up"&gt; &lt;h3&gt;{{ person.name }}&lt;/h3&gt; &lt;p&gt;{{ person.other_info }}&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; #Style Sheet div.pop-up { display: none; position: absolute; width: 280px; padding: 10px; background: #eeeeee; color: #000000; border: 1px solid #1a1a1a; font-size: 90%; } </code></pre> <p>So each person in the loop will have their avatar displayed, but when I scroll over their avatar, the information for the last person in the list is displayed. Anyone know what to do to fix it? Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload