0.0.12 • Published 11 years ago
pather v0.0.12
Pather.js
Drop-dead simple window.location.pathname listener
Disclaimer: This is work in progress
Works in browsers supporting the HTML5 History API, for older browsers, a polyfill like devote/HTML5-History-API is required.
Examples
Simple
Path.on("/foo/bar", function() {
console.log("Enter /foo/bar");
})
window.history.pushState({}, null, "/foo/bar")
Named parameters (Sinatra/Backbone style)
Path.on("/foo/:a/:b", function(a, b) {
console.log("Enter /foo/"+a+"/"+b);
})
window.history.pushState({}, null, "/foo/bar/baz")