我有学院列表..我已实现无限滚动但在列出记录时,记录正在获取重复值
index.html.haml
#academies
= render "academy",academy: params["search_form"]
.container.text-center
.col-sm-12
#page_links.pagination-text.scroll-pagination
= will_paginate @academies
index.js.erb的
$('#academies').append('<%= j render(@academies) %>');
<% if @academies.next_page %>
$("#page_links").hide();
$('.pagination').replaceWith('<%= j will_paginate(@academies) %>');
<% else %>
$('.pagination').remove();
<% end %>
<% sleep 1 %>
academies.coffe.erb
jQuery ->
if $('.scroll-pagination').length
$(window).scroll ->
url = $('a.next_page').attr('href')
if url && $(window).scrollTop() > $(document).height() - $(window).height() - 50
$("#page_links").show()
$('.pagination').html("<img src='<%= asset_path 'loader.gif' %>' alt='Loading...' title='Loading...' />")
$('.pagination').delay(100)
$.getScript(url)
$(window).scroll()
我不知道我哪里出错了请帮帮我 感谢