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

Unbind scroll event when reinstantiated #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pedantic-git
Copy link

There was a bug when elem.infinitePages() was called on a second element - the window.scroll was not unbound and so links generated still came from the old context/container.

In most cases, this one-line change fixes the turbolinks issues people are experiencing in #5. Just remember to reinstantiate infinitePages whenever turbolinks changes the page. For example (in my app):

ready = ->
  # Configure infinite table
  $('.infinite-table').infinitePages
    loading: ->
      $(this).text('Loading next page...')
    error: ->
      $(this).button('There was an error, please try again')
$(document).ready(ready)
$(document).on('turbolinks:load', ready)

@LannyBose
Copy link

LannyBose commented Apr 14, 2016

I inlined this one change locally and it fixed my issues with the following sequence (while using Turbolinks 5):

  • Visit an infinite scroller
  • Scroll once (but not to completion)
  • Navigate forward
  • Navigate back

...which previously had resulted in shenanigans. 👍

bendilley added a commit to skillstream/jquery-infinite-pages that referenced this pull request Sep 21, 2021
Scroll trigger would only take effect on first load: navigating back to
the same page would fail to auto-load the next page on scroll.

Solution from: magoosh#24
bendilley added a commit to skillstream/jquery-infinite-pages that referenced this pull request Sep 21, 2021
Scroll trigger would only take effect on first load: navigating back to
the same page would fail to auto-load the next page on scroll.

Solution from: magoosh#24
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

Successfully merging this pull request may close these issues.

2 participants