Descends from Cherrytree class. Accepts an Cherrytree options hash and renderRoot as arguments
Cherrytree options:
Option | Default | Description |
---|---|---|
log |
noop |
Called with logging info - takes true , false or a custom logging function |
logError |
true |
Called when transitions error (except TransitionRedirected and TransitionCancelled ). Takes true , false , or a custom function |
pushState |
false |
Use browser History API or the default hash change |
root |
/ |
Used in combination with pushState: true - if your app isn't served from / , pass the new root |
interceptLinks |
(same as pushState ) |
When pushState: true this intercepts all link clicks, preventing the default behavior. This can take a function to set custom behavior - see intercepting links |
qs |
object |
The parser function for query strings with a simple parser. Pass in an object with parse and stringify functions to customize the handling of query strings. |
renderRoot:
A Marionette Region or a HTML element or a CSS selector.
Optionally the render root can be defined setting a Marionette Region to rootRegion property
const router = new Router({log: true}, '#main');
Configures the route map. e.g.
router.map(function (route) {
route('app', {path: '/', abstract: true}, function () {
route('about', {viewClass: AboutView, viewOptions: {version: '1.0'}})
route('post', {path: ':postId', routeClass: PostRoute}, function () {
route('edit', {routeClass: PostRoute, viewClass: EditPostView})
})
})
})
Each route can be configure with the following options:
routeClass
: aRoute
classrouteOptions
: options passed to the Route constructorviewClass
: aMarionette.View
class. Can be used alone or withrouteClass
viewOptions
: options passed to the Marionette.View constructorpath
: the route pathabstract
: pass true to define an abstract routeoutlet
: pass true to allow a viewClass without anoutlet
region
All routes must have at least viewClass or routeClass defined.
For more information about route mapping refer to cherrytree documentation
Starts listening for URL changes
Property that defines the Marionette Region where the top level views will be rendered
Cleanup a router. This is mostly used for testing.