The relevant html for this is:
<table class="table" id="constraintTable">
<tr>
{% for header in headings %}
<th>{{ header }}</th>
{% endfor %}
<th>Action</th>
</tr>
{% for row in data %}
<tr>
{% for cell in row%}
<td>{{ cell }}</td>
{% endfor %}
<td id="editDelete">
<a href="#" id="editRow">Edit</a>
<a href="#" id="deleteRow">Delete</a>
</td>
</tr>
{% endfor %}
</table>
<button type="button" class="btn btn-primary" id="addConstraint" onclick="constraintAddToTable();>Add New Constraint</button>
Now Iam trying to add a row to this table using the following Jquery: (assuming the 'row' collection in the html above has only 2 entries)
function constraintAddToTable() {
if ($("#constraintTable tbody").length == 0) {
$("#constraintTable").append("<tbody></tbody>");
}
$("#constraintTable tbody").append("<tr>" +
"<td>" + "dataval1" + "</td>" +
"<td>" + "dataval2" + "</td>" +
$("#editDelete") +
"</tr>");
}
But this does not work. Only dataval1 and dataval2 gets in and the last column is just blank. I even tried adding the row without the edit/delete column and later adding the cloumn like this:
$("#constraintTable tr: last").append($("#editDelete"))
But this doesn't work as well. Any idea why this doesn't work and what needs to be done instead?