Route.js allows executing JavaScript code in the browser under a specific url
Include the Route.js script in your HTML markup:
<script src="js/route.min.js"></script>
In your application code, use the route() function like this:
//if the browser url is /some/url
route("/some/url", function(data)
{
//this code will run
});
You can get the url parameters
//if the browser url is /some/foo
route("/some/:id", function(data)
{
//this code will run and data.id is equal to 'foo'
});
You can use a wildcard to run the code in all the urls
route("*", function(data)
{
//this code will run in any url
});
The route() function accepts a string as first argument. The second argument must be a callback function, which is called if the first argument matchs with the browser url. The callback function receives only one argument, wich is an object with the url params.
Copyright 2015 Juan Ignacio Gipponi. Licensed under the MIT License. See the LICENSE file for more information.