How to add handler for click event on anchor tag in a column of Datatable ?
How to add handler for click event on anchor tag in a column of Datatable ?
kumarnishant342
Posts: 7Questions: 4Answers: 0
I have a DataTable. Because of performance issues, I am implementing server-side pagination. Now in 1 column there is an anchor element: <a class="btn btn-sm btn-success activate_illustration" style="padding:5px 10px;" data-path="/v0/dashboard/activate_illustration/7901-tiger">Clear flag & activate</a> in all rows.
I have to add handler for click event for each anchor element. How to do that ?
When the pagination was client-side, entire table was rendered and then handlers were attached to all anchor elements using this code:
$(".activate_illustration").click(function(){
...
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Sounds like your problem is documented in this FAQ. You need to use jQuery delegated events.
Kevin
Thanks. The solution you suggested worked fine.