Trigger jQuery to add events after AJAX-loading table in admin plugin
I created a small Wordpress plugin which has some admin-panels. I am using the WP_List_Table class to display some data, but this HTML-table is ajax loaded. Because of the ajax-loading, jQuery doesn't add functionality to the table, in particular the toggle functionality in a mobile (responsive) view. The toggle button appears, but clicking it does not show the hidden columns.
This is the HTML that is added after the ajax-call:
table class=wp-list-table widefat fixed striped table-view-list
thead
tr
th scope=col id=delete class=manage-column column-delete/th
th scope=col id=name class=manage-column column-name column-primaryName/th
th scope=col id=details class=manage-column column-spotsDetails/th/tr
/thead
tbody id=the-list
tr
td class=delete column-delete data-colname=
a onclick=deleteItem(6)delete/a
/td
td class=name column-name has-row-actions column-primary data-colname=Name
John
button type=button class=toggle-rowspan class=screen-reader-textShow details/span/button
/td
td class=spots column-details data-colname=DetailsHere some details.../td
/tr
/tbody
tfoot
...
/tfoot
The table displays as it should, however the toggle button is not working, probably because the table was added after the page load.
Is there a way to trigger the jQuery script after I reload the table?
Thanks!