In SharePoint 2013 I have a Site page with list view web part that contains calculated column. In this column the following function is executed to be able to open items in modal:
$(document).ready(function() {
$("a.viewItem").each(function() {
var headerid = $(this).parent().parent().parent("tr").attr("iid").split(",")[1]
var href = "URL"+headerid;
console.log(href);
var onlink = "openInDialog(500,500,true,true,true,'"+ href +"&IsDlg=1');"
$(this).attr('onclick', onlink);
});
});
Unfortunately, this works only on the first page of list view. If 2nd page is opened (next 30 items), the script is not executed.
How can I fix this so that it works for all list items?