Skip to content

A simple pagination API to paginate Mongoid Models or any other stuff...

License

Notifications You must be signed in to change notification settings

prathe/neat-pages

Repository files navigation

Neat Pages Build Status

A simple pagination API to paginate Mongoid Models.

Install

gem install neat-pages

Rails 3

In your Gemfile:

gem 'neat-pages'

Setup

First you need to link the assets.

In your css manifest put : require neat_pages

In your javascript manifest put : require neat_pages

You only need to require the javascript if you use the AJAX functionnality.

That's it.

Usage

Examples

Minimal integration

In your controller (app/controllers/products_controller.rb)

  def index
    paginate

    @products = Product.all.paginate(pagination)
  end

In your view (app/views/products/index.html.erb)

  <%= render 'products', products: @products %>
  <%= neat_pages_navigation %>

Summon the power of AJAX

In your controller (app/controllers/products_controller.rb)

  def index
    paginate

    @products = Product.all.paginate(pagination)
  end

In your view (app/views/products/index.html.erb)

  <%= neat_pages_ajax_items 'products', products: @products %>
  <%= neat_pages_navigation %>

Create the file app/views/products/index.neatpage.erb and place the following code in it.

  <% self.formats = ["html"] %>
  <%= render 'products', products: @products %>

Events

neat_pages:update

Triggered on 'body' whenever a page has changed, from cache or from server. The event data is an object literal which holds those fields:

noPage The current page number

Locales

If you want to translate the text in the pagination helpers, just add the following keys in i18n.

  fr:
    neat_pages:
      next_page: Page suivante
      previous_page: Page précédente

Copyright

Copyright (c) 2013 De Marque inc. See LICENSE for further details.

About

A simple pagination API to paginate Mongoid Models or any other stuff...

Resources

License

Stars

Watchers

Forks

Packages

No packages published