Im using ajax to render a table on my page. In the last row of the table Im trying to display a button which is handling my "edit" function like so:
$(".editPersonnel").on("click", function () {
$("#editPersonnelModal").modal("show");
$tr = $(this).closest("tr");
var data = $tr
.children("td")
.map(function () {
return $(this).text();
})
.get();
$("#idPer").val(data[0]);
$("#updateLastName").val(data[1]);
$("#updateFirstName").val(data[2]);
$("#updateJobTitle").val(data[3]);
$("#updateEmail").val(data[4]);
$("#updateDepartment").val(data[5]);
$("#updateLocation").val(data[6]);
console.log(data);
});
Im trying to render that button using jQuery but when I do this:
$("<td>").html(
'<td><button class="btn btn-info editPersonnel">Edit</button>'
)
the button shows on the page but doesn't work. Can anyone help me to solve this problem? Im still such a newbie... Thanks!