JQuery does not work when the form or a link is generated automatically. Example below:
This example works.
<a id='btnTreatInvite' class='btn btn-primary btn-sm fa fa-check' href='#'> Aceitar</a>
$("#btnTreatInvite").on("click", function(e){
e.preventDefault();
alert('event works');
});
When the same link is automatically generated, it does not work.
var table ='<table id="tableInviteRqd">';
table +='<thead>';
table +='<tr>';
table +='<th data-toggle="true">Nome</th>';
table +='<th data-hide="phone,tablet"></th>';
table +='</tr>';
table +='</thead>';
table +='<tbody>';
$.each(data, function(i, item){
table +='<td>' + item.name + '</td>';
table += "<td><a id='btnTreatInvite' class='btn btn-primary btn-sm fa fa-check' href='teste.php'> Aceitar</a></td>";
});
table +='</tbody>';
table +='</table>';