Informations

Rechercher

Archive pour le mot clé Fbml

will_paginate is one of the most used rails plugin. It take care of pagination of a large collectoon of item, automatically limiting records to display. It also display a pagination bar, with next, previous and numbered pages.

The fact is that by default, links are just normal link to relative path. It what you want most of the time. Some times you want some AJAX. There is manydifferentway to do it. But some times, you want some AJAX in a Facebook Application...

will_paginate allow us to use different renderer in order to customize our pagination. I've build one here. The prepare method is called by will_paginate to let us initialize our renderer before rendering anything. The main thing is to prepare url_for to return absolute, non canvas url because the Facebook FBJS AJAX proxy doesn't allow anything else.

In the page_link method, we generate links displayed by will_paginate. We can't set the href attribute to the url because again, the Facebook FBJS AJAX proxy doesn't allow anything but # here. And since in Profile Boxes and Tabs, we can't use onLoad event, we use onClick in order to call our AJAX builder. Parameters of that function are specific to my need, but it's just to show you that we can pass in variables and build a custom link.

Here is a sample code showing the way to specify our renderer to will_paginate.