Datatable Javascript Link not working on 2nd page

前端 未结 1 398
逝去的感伤
逝去的感伤 2021-01-26 15:32

I have a list of data in a table and am using the dataTable plugin for pagination.

However, my last column is a link. When I go to the 2nd page I cannot click the link,

相关标签:
1条回答
  • 2021-01-26 16:25

    You need to use a delegated event :

    Delegated events have the advantage that they can process events from descendant elements that are added to the document at a later time. By picking an element that is guaranteed to be present at the time the delegated event handler is attached, you can use delegated events to avoid the need to frequently attach and remove event handlers.

    So in your case, I would do this instead :

    $(document.body).on('click', '.PartsViewSubmit', function() {
        $.ajax({
            ...
        });
    });
    
    0 讨论(0)
提交回复
热议问题