Skip to content


Subversion checkout URL

You can clone with
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

50 lines (41 sloc) 2.055 kB


A lightweight and simple router for jQuery Mobile.


$.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){
  • routechange - fires each time the route is visited

    // For every page in "/admin/*"
    $.mobile.routerlite.routechange("/admin", function(page, path){
  • 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){
  • 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){

Each callback receives two parameters:

  • page - currently active jQuery mobile page
  • path - url path of the current route
Jump to Line
Something went wrong with that request. Please try again.