reinink / jQuery.Routy

A simple jQuery based router.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jQuery.Routy

Introduction

Routy is a simple jQuery plugin that allows you to tie application code to a specific page url (route) using regular expression matching. This helps organize JavaScript code in larger projects and removes the need for any in-line page identification, such an id on the body tag. Just minify all your JavaScript code into one file, and you're ready to go.

Examples

Basic usage

$.router('/calendar', function()
{
    console.log('This is the calendar page.');
});

Example using variables

$.router('/calendar/event/([0-9]+)', function(event_id)
{
    console.log('This is an event page with the id: ' + event_id);
});

Catch all example

$.router('/.*', function()
{
    console.log('This is run on every page.');
});

Questions or comments?

Send me a message on Twitter at @reinink.

About

A simple jQuery based router.


Languages

Language:JavaScript 100.0%