I want to apply multiple pagination with Kaminari via Ajax now here is my code for controller
def user_note
@user = current_user
@notes = Bookmark.where
I found this question searching for paginating multiple models on the same page. It's not clear to me how the pagination for the @notes collection is intended to work, but as presented, the solutions will only paginate the @bookmarks collection via AJAX.
There will be issues if you want to maintain pagination for both collections via html OR if you change the js file to render both collections.
I implemented a solution to my similar problem like this:
@notes
(including its pagination helper) and another that renders @bookmarks
with its pagination helperremote: true
One js view that re-renders the two partials, something like
$('#notes_container').html('<%= j(render partial: 'paginated_notes_list') %>');
$('#bookmarks_container').html('<%= j(render partial: 'paginated_bookmarks_list'); %>');
This is the key: Pagination links that take the current page of the other model as a parameter. This way you do not "lose" which page you are on in the other model.
<%= paginate @notes, param_name: 'page_1', params: {page_2: params[:page_2]} %>
<%= paginate @bookmarks, param_name: 'page_2', params: {page_1: params[:page_1]} %>
Again, I'm not really clear on how the asker's system is supposed to function, but this solution will allow user to page through both models without losing their "place" in the other model via AJAX or html.
you are missing to pass params at this line
$('#paginator').html('<%= escape_javascript(paginate(@bookmarks, :remote => true).to_s) %>');
i think it should be like this
$('#paginator').html('<%= escape_javascript(paginate(@bookmarks, :remote => true, :param_name => 'page_2').to_s) %>');
and you are also passing wrong param at this line
<%= paginate @bookmarks,:remote => true, :param_name => 'page' %>
it should be like this
<%= paginate @bookmarks,:remote => true, :param_name => 'page_2' %>
and please also check that whether you are sending the response correctly to the JS file or not.