Unable to click on newly added row

Unable to click on newly added row

dass2808dass2808 Posts: 3Questions: 2Answers: 0
edited April 2019 in Free community support

Hi Guys,

I have this code to add new row in datatable

dtTable.row.add([
 templateNo,
 "<a href='javascript:;'>" + templateName + "</a>",
 "<a href='javascript:;' title='@Resource.Delete' class='delete-template'><i class='fas fa-trash fa-lg text-danger'></i></a>"
]).draw();

But when I click on the newly added row it not triggering the click event

$('#access-template-table tr td:not(:last-child)').click(function (e) {

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @dass2808 ,

    This is probably due to not using delegated events - see this page of the FAQ. See the link it points to, it has this for the trigger:

    $('#example tbody').on('click', 'tr', function () {
    

    If that doesn't solve it, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin
    Cheers,

    Colin

This discussion has been closed.