GithubHelp home page GithubHelp logo

prathe / neat-pages Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 2.0 113 KB

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

License: MIT License

Ruby 76.76% CoffeeScript 22.99% JavaScript 0.25%

neat-pages's Introduction

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.

neat-pages's People

Contributors

fbernier avatar prathe avatar

Watchers

 avatar  avatar

Forkers

alchimikweb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.