MVCGrid.Net Paging unregistering jQuery event

90 Views Asked by At

I have a document ready event registering a click event on the grid, everything works fine on page load however after I use pagination to move to the next page, the event is unregistered. Is this a known issue or does anyone know how to re-register the table click event after paging to the next page?

    $('.table > tbody > tr').on('click', function () {

        var row = $(this).closest('tr');
        var jobNumber = row.find('td:nth-child(3)').text();

        alert(jobNumber);

    });
1

There are 1 best solutions below

0
Mike Ike On BEST ANSWER

The problem is that the grid does a partial page load on pagination, the solution below worked for me although it's not that elegant.

$(document).click(function (e) {

    if ($(e.target).is(".table > tbody > tr > td")) {

        var parentRow = $(e.target).closest('tr');
        var jobNumber = parentRow.find('td:nth-child(3)').text();

        alert(jobNumber);
    }
});