Class: Router

Router

new Router(controller, routes)

Parameters:
Name Type Description
controller Object
routes Object
Source:
Example
var controller = {layout: ...};
var router = new Router(controller, {...routes})
router.parse(controller.layout);
router.route();

Members

(static) base :String

Base subpath if app is not running on root

Type:
  • String
Source:

(static) rewrite :Boolean

wheter urls should be rewritten or not (if not uses query string ?route=path/to/route)

Type:
  • Boolean
Source:

Methods

(static) fetch(routes, path)

finds a specific path in defined routes

Parameters:
Name Type Description
routes Object
path String
Source:

(static) generate(path)

generates a full url to a specific route taking rewrite rules into account

Parameters:
Name Type Description
path String

for which a full url should be generated

Source:

(static) get(url)

generates the corresponding path of the current or a specified url, stripping out the domain and base path

Parameters:
Name Type Description
url String

(optional)

Source:

destroy()

destroy current router instance

Source:

parse(container)

parses a dom container for href's, and binds click events to internal links

Parameters:
Name Type Description
container DOMElement
Source:

route()

fetches route and calls controller, should be called when first instantiating the router

Source:

to(path)

switches to a specific path

Parameters:
Name Type Description
path String

that should be switched to

Source: