1.0.0 • Published 9 years ago

hello-router v1.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
9 years ago

hello-router

Build Status

client-side router for SPA


Install

npm install hello-router

API

  • .register(uri, action)
  • .activate(uri)
  • .dispatch(uri)
  • .redirect(uri)
  • .run()

Usage

var router = helloRouter;

router.register('/a', function () {
	// do something
	
	router.redirect('/b');
	// ignore follow code
});

router.register('/b', function () {
	// do something
	
	router.dispatch('/404');
	// ignore follow code
});

router.register('/404', function () {
	// do something
});

router.run();

// <a href="/hello/router?age=1"></a>
$('a').click(function () {
	router.active(this.href);
	return false;
});