0.1.8 • Published 8 years ago

routebeer v0.1.8

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

routebeer

A simple router for the browser best enjoyed with pjax

Some API Changes in version 0.1.8

Usage

var routebeer = require('routebeer')

var router = routebeer({
	always : function (data) { // run on every navigate
		console.log(data)
	},
	notFound : function (data) { // run on route not found
		console.log(data)
	},
	root : '/', // define optional base
	event : 'pjax:success' // run route check on event
})
.add({ // add a route
	name : 'project',
	path : '/projects/:project',
	load : function (r) { // run when navigating to route
		console.log(r) // r will contain route data, such as params
	},
	unload : function (r) { // run when navigating away from route
		console.log(r)
	}
})
.add({
	name : 'about',
	path : '/about',
	load : function (r) {
		console.log(r)
	},
	unload : function (r) {
		console.log(r)
	}
})
.add({
	name : 'home',
	path : '/',
	load : function (r) {
		console.log(r)
	},
	unload : function (r) {
		console.log(r)
	}
})
.navigate() // init

Path definition using path match

Remove

router.remove('home') // removes route

Events

router
	.on('load', function (r) {

	})
	.on('unload', function (r) {

	})

Bundled Version

If you don't want to mess with a build process you can also include the pre-bundled version found in routebeer.bundled.js in your project which exposes routebeer() globally.

0.1.8

8 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago