Git Product home page Git Product logo

jquery.page-it's Introduction

Page it!

A simple jQuery dependent library to create paginations!

With this lib you can fully manipulate pagination events and fetch information from an endpoint.

Also you can, in fact you must (if you want to use it), integrate this tool with your own pagination component.

Instalation

Download it via npm:

npm i jquery.page-it@latest --save

Available Methods

Methods Params Description
first void Loads first page.
prev void Loads previous page.
next void Loads next page.
last void Loads last page.
to {int} pageIndex Loads the specifyied page.
on {string} eventName, {callable} callback Registers an event listener.
trigger {string} eventName, {array} params Triggers an event.
setMeta {object} meta (see meta schema) Sets the meta property, this property is used to control pagination numbers.
setCurrent {int} current Sets the current page and updates dependent meta.
setRequestData {object} requestData Accepts a callback to update the request data.

Options

Default options are:

{
    /**
     * @var {bool} autoStart : If should auto start loading the current page or not.
     */
    autoStart: false,
    /**
     * @var {bool} cache : If should store loaded pages (and load'em from) in a local storage or not
     */
    cache: true,
    /**
     * @var {object} ajax : jQuery.AJAX configuration options.
     */
    ajax: {
        url: '',
        cache: false,
        global: true,
        method: 'get',
    },
    /**
     * @var {HTMLElement} target : If you define this, you will have auto page content updates
     */
    target: null,
    /**
     * @var {string} fillMode : The fill mode to use when pagrIt will do something with the target.
     */
    fillMode: 'replace',
    /**
     * @var {object} meta : The meta information used for controlling the things.
     */
    meta: metaSchema
}

Meta Schema

{
    /**
     * @var {int} size : Items per page.
     */
    size: null,
    /**
     * @var {int} first : Whats the first page of the collection.
     */
    first: 1,
    /**
     * @var {int} prev : Whats the previous page behind current.
     */
    prev: null,
    /**
     * @var {int} current : Current page number.
     */
    current: null,
    /**
     * @var {int} next : Whats the next page from current.
     */
    next: null,
    /**
     * @var {int} last : Whats the last page of the collection.
     */
    last: null,
    /**
     * @var {int} total : The total quantity of pages.
     */
    total: null
}

jquery.page-it's People

Contributors

odahcam avatar

Watchers

 avatar  avatar

jquery.page-it's Issues

Drop all the shit. Nigga.

Drop jQuery hell dependency. Use:

var request = new XMLHttpRequest();
request.open('GET', '/my/url', true);

request.onload = function() {
  if (request.status >= 200 && request.status < 400) {
    // Success!
    var resp = request.responseText;
  } else {
    // We reached our target server, but it returned an error

  }
};

request.onerror = function() {
  // There was a connection error of some sort
};

request.send();

Drop JSON dependency, use the fucking HTTP custom headers!! Use:

var req = new XMLHttpRequest();
req.open('GET', document.location, false);
req.send(null);
var headers = req.getAllResponseHeaders().toLowerCase();
alert(headers);

Do some cool stuff:

xhr.onprogress = function(){
    // a cool progress bar, maybe?
}

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.