Using jQuery, I get HTML data with the $.get()
function. In callback function, when I put a breakpoint, the data variable is not empty and I see my link with the proper class (deleteLink
), so I can select it.
$.get(path, function(data) {
$(data).find("a.deleteLink").click(function(event) {
event.preventDefault();
DeleteRow(event);
});
$("#tbody_id").append(data);
});
Example of data received:
<tr>
<td>Some data</td>
<td><a href="#" class="deleteLink">X</a></td>
</tr>
I've tried to append()
data after and before assigning the event listener to the link. Having no JS error when I receive data, having the good element returned with $(data).find("a.deleteLink")
function, having also the correct <tbody>
element returned by $("#tbody_id")
, and no error when I click on link, why DeleteRow()
is never called?