Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattbryson/backbone.historyevents
Extra events for the Backbone History module.
https://github.com/mattbryson/backbone.historyevents
backbone-framework backbonejs
Last synced: about 1 month ago
JSON representation
Extra events for the Backbone History module.
- Host: GitHub
- URL: https://github.com/mattbryson/backbone.historyevents
- Owner: mattbryson
- License: mit
- Created: 2017-02-28T17:21:39.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-15T11:29:22.000Z (almost 8 years ago)
- Last Synced: 2024-12-08T12:15:52.317Z (about 2 months ago)
- Topics: backbone-framework, backbonejs
- Language: JavaScript
- Size: 30.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# backbone.historyEvents
Extra events for the Backbone History module.
This simply adds a couple of events to the `Backbone.history` module, allowing you to respond to things
like missing routes and changes to the URL (even when a route is not triggered)## Install
````bash
npm install backbone-history-events --save
````````bash
bower install backbone-history-events --save
````## Example
````javascript
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}
````````javascript
Backbone.history.on('routeNotFound', function(fragment){
console.log('Page Not found ', fragment);
});Backbone.history.navigate('/nonExistentRoute', {trigger:true});
// Page Not found nonExistentRouteBackbone.history.navigate('/nonExistentRoute');
// Handler is not triggered as nothing tried to load a route (no trigger)
````## Docs
See [https://mattbryson.github.io/backbone.historyEvents] for documentation