I have a user's list
, when click on 'show activities' this shows a list of user activities in a modal from partial file _user_activities.html.haml
. This activities list is a paginated view. I want to add pagination only for this activities alone inside my modal window. How to do this? I am already using will_paginate
, that makes my page to reload. How to achieve this?
users/index.html.haml
%table
%thead
%th Name
%th Actions
%tbody
- @users.each do |user|
%tr
%td= user.name
%td
%i.icon-play
%div.modal.hide
= render 'user_activities', user: user
= will_paginate users
:javascript
$('i').click(function() {
$(this).next(.modal).modal('show');
});
users/_user_activities.html.haml
%table
%thead
%th Name
%td Type
%tbody
- user.activities.eadch do |activity|
%tr
%td= activity.name
%td= activity.type
= will_paginate user.activities
You can use kamiray or will_paginate gem very easy to use have a look at following example using will paginate,
do this in your controller and it will add pagination.
here is a railscast for Kaminary and willpaginate Hope it would solve your problem.
One way to achieve the ajax type pagination is with Kaminary gem. We can easily set up the pagination with Kaminary. I don't know how to achieve the ajax type pagination with
will_paginate
, but i usedkaminary
in my one of project and its quite easy with this.update
Check How to Implement ajax pagination with will_paginate gem for providing the ajax type pagination with
will_paginate
.