In my Rails app I'm using will_paginate and partials to make it so you can click through pages of a list without the page refreshing. This is the JS I use to call the partials and do it all:
$(function () {
$('.pagination a').on("click", function () {
$.get(this.href, null, null, 'script');
return false;
});
});
For some reason, however, it works just fine when I click a link the first time; replaces the partial with an updated one. However after that, I click the next pagination anchor link and the page does a full refresh. Any idea why? My thinking is that this JS only executes when the DOM is initially loaded and so when the partial is replaced with one containing new links they aren't wired up to this code. If this is correct, how would I go about fixing it?