Scroll down pagination in rails using will_paginate - ruby-on-rails

I wanna use infinite scroll down pagination in rails and want to pass the information like page number so that next data can be retrieved in the action and for the scroll down i can append the data to the existing data in my view.
is there any thing scroll down pagination that we can do with the will_paginate?
Thanks in advance
--Vam.

This Jquery plugin may help https://github.com/jney/jquery.pageless

to see how to do this yourself, have a look at
http://railscasts.com/episodes/174-pagination-with-ajax
to see how to use will_paginate with ajax (jquery). Ryan shows how to modify the usual will_paginate approach. First how to modify the links of the pagination bar and then he shows how to modify the view to display newly loaded objects... In this video he replaces shown items by newly loaded items. You'd just have to tweak the index.js.erb to append them.
nevertheless ... you might also want to checkout his video
http://railscasts.com/episodes/114-endless-page
in which he shows what you asked for but without will_pagination

Related

Any 3 party controls or ideas to for UItableview pagination like google search result

Pagination for next, previous and pagenumber
Here is link:
https://github.com/xmartlabs/XLPagerTabStrip
Pagination for next, previous and pagenumber can be just two buttons and you can trigger nextpage action on it.
Take a look here https://www.cocoacontrols.com/controls/sypaginator maybe it is what you want. Or I believe it can be easily customized to exact form you want.
Another solution for you can be to show an HTML wrapped content in UIWebView...

Rails lazy loading

I have an app which has an index page that shows currently 10 search results. Rather than doing the standard lazy load with javascript, similar to the Railscast where new objects are shown when the user gets to the bottom of the page, I would like to have to page have a button on the bottom. When that button is clicked, I would like the next 10 objects from the search results to show and so on. Is there a tutorial for this/how would I do this?
you should use gem like
https://github.com/amatsuda/kaminari or https://github.com/mislav/will_paginate.

Rendering controller/action within a different view

I am looking for a way in Ruby on Rails to render a completely different controller's action within other views.
For example I am writing a band website that displays their albums. So I have /albums/list that shows a list of all of their albums with other stuff around the page as the layout. Now what I am looking to do is also render /news/list in every page as part of the layout as well so that every page you go to you can see it.
I cannot find a way to call the news controller list action and display it in the list view using partial views. Any help would be appreciated.
http://api.rubyonrails.org/classes/ActionView/Helpers/RenderingHelper.html#method-i-render
render() method give you ability to render specific file, placed in any directory :)
also read this article - http://blog.plataformatec.com.br/2012/01/my-five-favorite-hidden-features-in-rails-3-2 especially about "Custom partial paths".

jquery accordion with dynamic content

My initial page has an empty div. An ajax transaction fills it with suitable h3/div content. If I call .accordion() before there's any content, it has no effect. If I call it after the first content is loaded, the first content looks good. Calling it a second time, however, does not work. Do I really need to destroy and redo?
At the moment you have to destroy and re-create the whole thing using the official stable release. There is already a feature request for it, scheduled for 1.next: http://bugs.jqueryui.com/ticket/4672
If you have a read above, mrfr0g says he built a custom accordion based on jQuery UI 1.8.2, give that a try.
give the inner DIV of each tab an id
and use document.getElementById("content1").innerHTML = "HelloEveyOne345443333334422" to dynamically change the content of each tab

Ajax pagination like Twitter

Is there any plugin/gem or an easy way for accomplish a pagination functionality like Twitter?
This means, showing a "More" button that shows more posts (for example) below once it's clicked, using Ajax.
If there's any easy way for modifying something from will_paginate plugin, that would be useful too.
I use this for easy pageless pagination. Seems to be a better solution w/o the more button.
http://github.com/jney/jquery.pageless
I've added a Twitter-like 'more' button on the app I'm currently working on. I used the exact method from http://railscasts.com/episodes/114-endless-page.
In this solution, more results are added to the bottom of the div once you scroll down to the bottom of the page resulting in an endless page. I changed the javascript so that it would send off the ajax request to add more results to the bottom of the div only when the 'load more' button is clicked.
The will_paginate project wiki has an entry on Ajax pagination. It's really quite straightforward.
I use Twitter-like pagination in one of my apps, so I'll just point you to that:
http://github.com/tsigo/jugglf/blob/master/lib/twitter_pagination.rb - Hooks into will_paginate to display the "More" button
http://github.com/tsigo/jugglf/blob/master/app/views/members/raids/index.html.haml - The view using the renderer from above
http://github.com/tsigo/jugglf/blob/master/app/views/members/raids/index.js.erb - The RJS view that appends the next set to the page

Resources