Frage

I'm using jQuery.pageless (for infinite scrolling) on my rails app. (https://github.com/jney/jquery.pageless)

Everything works great except when using turbolinks. When using turbolinks, it just defaults to basic will_paginate look. Anything I can change to get this working properly with Turbolinks?

here are a few files

controller:

@users = @user.followed_users.paginate(:per_page => 10, :page => params[:page])
if request.xhr?
  render :partial => @users
end

application helper:

def pageless(total_pages, url=nil, container=nil)
  opts = {
    :totalPages => total_pages,
    :url        => url,
    :loaderImage => image_path("load.gif")
  }

  container && opts[:container] ||= container

  javascript_tag("$('.controller-container').pageless(#{opts.to_json});")
end

view:

<%= render(:partial => "user", :collection => @users) %>
<%= will_paginate(@users) %>
<%= pageless(@users.total_pages, user_followers_path(@user)) %>

and this is the JS file used: https://github.com/jney/jquery.pageless/blob/master/lib/jquery.pageless.js

I know many people have problems with some JavaScript libraries and Turbolinks and I need to find a workaround to get these JS libraries, like jQuery.pageless, to work with Turbolinks...

Thanks

War es hilfreich?

Lösung

Unfortunately pageless cant be used with turbolinks now. I've patched it to make it work and I'm going to create a pull request later.

https://github.com/amenzhinsky/jquery.pageless/commit/8f7797be3a29612f5aad703b803bef7416fa576a

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top