Class Index | File Index

Classes


Class LocationRouterConstructor

A locationRouter is a router which navigates to the route defined in the URL and updates this URL while navigating. It's a subtype of Emily's Router
Defined in: LocationRouter.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
 
Remove the events handler for cleaning.
 
Get the currently set default route
 
parse(hash)
The function that parses the url to determine the route to navigate to.
 
setDefaultRoute(defaultRoute)
Set the default route to navigate to when nothing is defined in the url
 
start(defaultRoute)
When all the routes and handlers have been defined, start the location router so it parses the URL and navigates to the corresponding route.
 
toUrl(args)
The function that converts, or serialises the route and its arguments to a valid URL.
Class Detail
LocationRouterConstructor()
Method Detail
destroy()
Remove the events handler for cleaning.

{String} getDefaultRoute()
Get the currently set default route
Returns:
{String} the default route

{Array} parse(hash)
The function that parses the url to determine the route to navigate to. It has a default behavior explained below, but can be overriden as long as it has the same contract.
Parameters:
{String} hash
the hash coming from window.location.has
Returns:
{Array} has to return an array with the list of arguments to call navigate with. The first item of the array must be the name of the route. Example: #album/holiday/2013 will navigate to the route "album" and give two arguments "holiday" and "2013"

{Boolean} setDefaultRoute(defaultRoute)
Set the default route to navigate to when nothing is defined in the url
Parameters:
{String} defaultRoute
the defaultRoute to navigate to
Returns:
{Boolean} true if it's not an empty string

start(defaultRoute)
When all the routes and handlers have been defined, start the location router so it parses the URL and navigates to the corresponding route. It will also start listening to route changes and hashmark changes to navigate. While navigating, the hashmark itself will also change to reflect the current route state
Parameters:
defaultRoute

{String} toUrl(args)
The function that converts, or serialises the route and its arguments to a valid URL. It has a default behavior below, but can be overriden as long as it has the same contract.
Parameters:
{Array} args
the list of arguments to serialize
Returns:
{String} the serialized arguments to add to the url hashmark Example: ["album", "holiday", "2013"]; will give "album/holiday/2013"

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 05 2014 00:25:22 GMT-0500 (EST)