I have a single php page that loads a table with pagination using jquery/ajax. I am unable to get the rows to redirect to a different page once any page in the pagination is clicked (other than the initial page)
Here is simplified code of my generated html for the table. I know the html is generated correctly each time pagination page is changed.
<tr class="table-row" data-myredirect="http://example.com/page">
<td>blah blah</td>
</tr>
Upon success of loading the table data (only run once after user runs a query), i run the following (simplified):
success:function(result){
//display table data (not shown)
$(".table-row").click(function() {
//redirect
window.document.location = $(this).data("myredirect");
});
}
When user selects a different page from the pagination links, the following is run:
//executes code below when user click on pagination links
$("#results").on( "click", ".pagination a", function (e){
e.preventDefault();
$(".loading-div").show(); //show loading element
var page = $(this).attr("data-page"); //get page number from link
$("#results").load("test.php",{"page":page, "myparam":searchItemOne}, function(){ //get content from PHP page
$(".loading-div").hide(); //once done, hide loading element
//fixes scrolling up bug
$('html, body').animate({
scrollTop: $("#results").offset().top
}, 0);
});
});
What might be causing the action to no longer work once I navigate to the next pagination page? I can include more code upon request.