Create an instance of a router that responds to hashchange and popstate events.
- Source:
Methods
addRoute(path, callback)
#
Bind a specific callback to a hash-based route.
addRoute( 'alert', function () { alert( 'something' ); } );
addRoute( /hi-(.*)/, function ( name ) { alert( 'Hi ' + name ) } );
Note that after defining all available routes it is up to the caller to check the existing route via the checkRoute method.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | RegExp | Path to match, string or regular expression |
callback |
function | Callback to be run when hash changes to one that matches. |
- Source:
back() → {jQuery.Promise}
#
Navigate to the previous route. This is a wrapper for window.history.back.
- Source:
Returns:
Promise which resolves when the back navigation is complete
- Type
- jQuery.Promise
checkRoute()
#
Check the current route and run appropriate callback if it matches.
- Source:
isSupported() → {boolean}
#
Whether the current browser supports 'hashchange' events.
- Deprecated:
- No longer needed
- Source:
Returns:
Always true
- Type
- boolean
route()
#
- Deprecated:
- Use
module:mediawiki.router#addRoute
instead.
- Use
- Source:
Events
hashchange()
#
- Source:
popstate()
#
- Source: