Giter Club home page Giter Club logo

jquery-mobile-routerlite's Introduction

jquery-mobile-routerlite

A lightweight and simple router for jQuery Mobile.

Why

$.mobile.routerlite was created to give you exactly the power you need to handle routes properly in jQuery Mobile with a straightforward API. routerlite just gives you four simple methods: routeinit, routechange, pageinit and pagechange. You can bind a callback either when a route or page is first visited, or everytime a certain route or page is visited.

There are a lot of different types of page events in jQuery Mobile and sometimes it's hard to figure out which one to bind to and also how to get the current page context when that event fires. So routerlite helps you with normalizing event data so you don't have to do any guesswork. routerlite normalizes this for you and gives you the current page and path context every time you handle a route or page change.

API Methods

$.mobile.routerlite has four methods:

  • routeinit - only fires once when the route is first visited

    // When "/admin" is first visited
    $.mobile.routerlite.routeinit("/admin", function(page, path){
        doSomething();
    });
  • routechange - fires each time the route is visited

    // For every page in "/admin/*"
    $.mobile.routerlite.routechange("/admin", function(page, path){
       doSomething();
    });
  • pageinit - only fires once when the page is first visited

    // if we see page with id="checkout" then run this code
    $.mobile.routerlite.pageinit("#checkout", function(page){
        doSomething();
    });
  • pagechange - fires each time the page is visited

    // every time we visit the page with id="checkout" then run this code
    $.mobile.routerlite.pagechange("#checkout", function(page){
        doSomething();
    });

Each callback receives two parameters:

  • page - currently active jQuery mobile page
  • path - url path of the current route

jquery-mobile-routerlite's People

Contributors

1marc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-mobile-routerlite's Issues

routechange not firing on children with # routes

I had no idea how to create a title that would not be that cryptic ;)

$.mobile.routerlite.routechange("/", function(page, path){ console.log('!'); });

The code above logs to console on every page I visit except it doesn't log anything when I go to a page that is not loaded from a path, like: /#pageB

Is that desired? I would understand it's not a route change, but I can do:

$.mobile.routerlite.routechange("pageB", function(page, path){ console.log('hmm'); });

and it works.

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.