enter image description hereI am new to web development and struggling with a very simple issue. Please help me with a fix for this issue as I have not been able to move forward with my work.
Requirement: I make an AJAX call to a django URL that gets me the data. I render the table using jsrender template. I have been able to get the table rendered just the way it is needed.
Issue : The last column is a font awesome icon that when user clicks on should call a jQuery function that opens up a modal dialog and allows the edits. On click of the icon, nothing happens as I think the icon is not accessible for any events. Have I missed out some kind of update post jsrender that is making this icon not accessible for click.
I had the same issue with jsrender and chosen-select. Found a hit in SO that post rendering, I need to udpdate the list with $("#name_of_list").trigger("chosen:updated"); Do I need to do something similar for the table / datatable.
Please note that since django uses the tags {{ }} for rendering, I had to set jsRender to use [% %]
below is my code...
AJAX Call
function ajaxcall(pdata, purl, ptpl, pplh){
$.ajax({
type: "GET",
url: purl,
data: pdata,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(ldata){
var ltemplate = $.templates(ptpl);
var lldata = ltemplate.render(ldata);
$(pplh).html(lldata);
console.log(lldata);
jsRender Template
<script id="tpl_userroles" type="text/x-jsrender">
<tr>
<td>[%>id%]</td>
<td>[%>userrolename%]</td>
<td>[%>defaultrole%]</td>
<td>[%>bu%]</td>
<td>[%>sbu%]</td>
<td>[%>sl%]</td>
<td>[%>ssl%]</td>
<td>[%>geo%]</td>
<td>[%>sgeo%]</td>
<td>[%>urstatus%]</td>
<td>[%>startdate%]</td>
<td>[%>enddate%]</td>
{% for imodulesaccessur in lmodulesaccessur %}
{% if imodulesaccessur.updateallowed == 'Y' %}
<td><a class="plus-link pull-right"><i class="fa fa-pencil text-navy icn_edituserrole" data-toggle="modal" data-target="#mod_edituserrole"></i></a></td>
{% else %}
<td></td>
{% endif %}
{% endfor %}
</tr>
</script>