History

History

Events

navigated

Source:

This is always triggered when Backbone.history.navigate is executed, regardless if any routes matched or not.

Example
Backbone.history.on('navigated', function(fragment, options, routeTriggered){
 console.log('Navigated to ', fragment, '. Triggered router:', routeTriggered, ' with options ', options );
});

Backbone.history.navigate('/myRoute', {trigger:true});
// Naivagted to  /myRoute . Triggered router: true  with options  Object {trigger: true}
Parameters:
Name Type Description
routeTriggered boolean

If the url triggered a router handler

fragment string

The fragment requested

options object

The original options passed into the Backbone.History.navigate call

Returns:

If the route was triggered or not

Type
boolean

routeNotFound

Source:

Triggered if Backbone.history.loadUrl fails to match a router handler for the fragment

Example
Backbone.history.on('routeNotFound', function(fragment){
 console.log('Page Not found ', fragment);
});

Backbone.history.navigate('/nonExistantRoute', {trigger:true});
// Page Not found nonExistantRoute

Backbone.history.navigate('/nonExistantRoute');
// Handler is not triggered as nothing tried to load a route (no trigger)
Parameters:
Name Type Description
fragment string

The fragment requested

Returns:

If the route was triggered or not

Type
boolean