2016-05-26 4 views
1

私がタブ2にいるときに3ページの例をクリックすると、ページがリフレッシュされ、タブ1に戻ります。この問題を解決するにはAJAXが必要ですしかし、私はそれにいくつかの助けを使うことができます。Rails:will_paginateのためのAJAXの実装方法

前にいくつかの例を試しましたが、どれもうまくいきませんでした。

私はこれをどのように唯一の手助けしてください。前もって感謝します!

コントローラー:

私の見解インサイド
class ProfilesController < ApplicationController 
    def show 
    @fullname = current_user.first_name + " " + current_user.last_name 
    @recipes = current_user.recipes.page(params[:recipes_page]).order("created_at DESC") 
    @favorites = current_user.favorites.page(params[:favorites_page]).order("created_at DESC") 
    end 
end 

<div class="apple_pagination"> 
    <%= will_paginate @recipes, param_name: "recipes_page" %> 
</div> 

<div class="apple_pagination"> 
    <%= will_paginate @favorites, param_name: "favorites_page" %> 
</div> 

答えて

1

これを試してみてください:

<div class="apple_pagination"> 
    <%= will_paginate @recipes, :remote => true , param_name: "recipes_page" %> 
</div> 

<div class="apple_pagination"> 
    <%= will_paginate @favorites, :remote => true , param_name: "favorites_page" %> 
</div> 
関連する問題