title: How to get data-id in list html to javascript in django template?
body: <p>I'm trying to list several elements and have the possibility to edit them through a modal, I tried to use the data-id property but that way it only works with the first element of the list.</p>
  
  <p>This my Html:</p>
  
  <pre class="lang-html prettyprint-override"><code>{% for job_title in job_title_list %}
      &lt;tr&gt;
          &lt;td align="center"&gt;&lt;div style="width:200px"&gt;{{job_title.title}}
            &lt;a class="col-xs-1 text-info" data-id="{{job_title.id}}" data-title="{{job_title.title}}" id="update_{{ job_title.pk }}" href="#" data-toggle="modal" data-target="#UpdateModal"&gt;
                  &lt;i class="glyphicon glyphicon-edit"&gt;&lt;/i&gt;
              &lt;/a&gt;    
           &lt;/div&gt; 
  
          &lt;/td&gt;
      &lt;/tr&gt;
    {% endfor %}
  
  </code></pre>
  
  <p>This my javascript:</p>
  
  <pre class="lang-js prettyprint-override"><code>//update
          $("#update_{{ job_title.pk }}").click(function(){
              var id = $(this).data("id");
              var title = $(this).data("title");
              $("#update_title").prepend(
                  "&lt;div id='title_to_update'&gt;&lt;label&gt;{% trans 'Nome do cargo' %}&lt;/label&gt;&lt;input id='job_title' class='form-control' name='title_to_update' value=' ' /&gt;&lt;/div&gt;"
              );
              document.getElementById("job_title").value = title;
  
              $("#update_sts").prepend(
                  "&lt;div id='sts_to_update'&gt;&lt;select class='form-control' id='new_sts' name='new_sts'&gt; {% if l.status == '1' %}&lt;option value='1'&gt;{% trans 'Ativo' %}&lt;/option&gt;&lt;option value='0'&gt;{% trans 'Inativo' %}&lt;/option&gt; {% else %} &lt;option value='0'&gt;{% trans 'Inativo' %}&lt;/option&gt;&lt;option value='1'&gt;{% trans 'Ativo' %}&lt;/option&gt; {% endif %} &lt;/select&gt;&lt;/div&gt;"
              );
          });
  </code></pre>