Load More Scrolling using jQuery in Rails 3.1
<p>I am trying to implement "Load More" type of endless scrolling in my rails application. This is my javascript code:</p>

<pre><code>$(document).ready(function() {
  var currPage = 1;
  $("a.next").live("click", function() {
    loadMore(++currPage);
  });
});


function loadMore(pageNo) {
  var url = '/users?page=';
  $.get(url+pageNo, function(data) {
    $(".users").append(data);
    alert('Load was performed.');
  });
}
</code></pre>

<p>Every time the "Load More" (given in the a.next tag) button is pressed, along with the next page, the current page renders and is appended to the page. This way I go into an endless loop upon clicking "Load More" many number of times.</p>

<p>Please help.</p>
