Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not triggered with page scroll #21

Open
deha23 opened this issue Jan 25, 2016 · 3 comments
Open

not triggered with page scroll #21

deha23 opened this issue Jan 25, 2016 · 3 comments

Comments

@deha23
Copy link

deha23 commented Jan 25, 2016

I am able to trigger the infinite scroll manually with "$('.infinite-table').infinitePages('next')"
but nothing happens when I am scrolling. Any Ideas?
Thanks in advance

@deha23
Copy link
Author

deha23 commented Jan 25, 2016

Sorry for the disturbance. I found the error. It was a false intendation

@frankolson
Copy link

frankolson commented Sep 21, 2017

@deha23 I am running into a similar problem and cannot figure out a solution. The manual commands work, but page scrolling will not trigger an ajax call. I do not have Turbolinks and here is my setup:

<!-- _user.html.erb -->
<% @users.each_slice(2) do |user_row| %>
  <div class="row">
    <% user_row.each do |user| %>
      <div class="col-xs-12 col-md-6">
        <!-- partial for user card -->
        <%= render partial: 'users/users_search_results', locals: {user: user} %>
      </div>
    <% end %>
  </div>
<% end %>
<!-- index.html.erb -->
<div class="infinite-scrolling">
  <div class="user-search-results">
    <%= render :partial => 'users', :object => @users %>
  </div>
  <p class="pagination text-center">
    <%= link_to_next_page(@users, 'Next Page', :remote => true) %>
  </p>
</div>
<!-- index.js.erb -->
// Append new data
$("<%=j render(:partial => 'users', :object => @users) %>")
  .appendTo($(".user-search-results"));

// Update pagination link
<% if @users.last_page? %>
  $('.pagination').html("That's all, folks!");
<% else %>
  $('.pagination')
    .html("<%=j link_to_next_page(@users, 'Next Page', :remote => true) %>");
<% end %>
# infinitScrolling.js.coffee
$ ->
  # Configure infinite table
  $('.infinite-scrolling').infinitePages
    # debug: true
    loading: ->
      $(this).text('Loading next page...')
    error: ->
      $(this).button('There was an error, please try again')

Again, submitting the following commands in the developer's console:

$('.infinite-scrolling').infinitePages('next')
$('.infinite-scrolling').infinitePages('pause')
$('.infinite-scrolling').infinitePages('resume')

works perfectly fine, but scrolling will not activate the ajax call, debugging messages, or even the loading text.

@frankolson
Copy link

I couldn't get it to work so I ended up following this tutorial using a different plugin:
https://christianvarga.com/simple-infinite-scroll-with-rails-and-jquery/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants