title: Facebook Share button with facebook javascript sdk in a django template for loop
body: <p>I am having a little trouble getting this to work, I want to generate a facebook share button for each post on my website, but the way I have it set I only get a working share button for the first button instance and it only shares the very last post that is on the page, none of the other share buttons do anything.</p>
  
  <p>Relevant Code</p>
  
  <p>blog/post_list.html</p>
  
  <pre><code>{% extends 'blog/base.html' %}
  {% load cloudinary %}
  {% block content %}
     &lt;div id='posts'&gt;
       {% for post in posts %}
  
          [...]
  
          &lt;div id="shareBtn" class="btn btn-success clearfix"&gt;Share&lt;/div&gt;
          &lt;script&gt;
                  document.getElementById('shareBtn').onclick = function() {
  
                  FB.ui({
                      method: 'share',
                      display: 'popup',
                      href: 'http://example.com:8000{{ post.get_absolute_url          }}',
                    }, function(response){});
                  }
          &lt;/script&gt;
      {% endfor %}
  
      [...]
  
  {% endblock %}
  </code></pre>