Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- routes: {
- 'lions': 'animalsRoute',
- 'animals': 'animalsRoute'
- },
- animalsRoute: function() {
- this.navigate("#/animals", { replace: true });
- // or using the global history object:
- // Backbone.history.navigate("#/animals", { replace: true });
- }
- routes: {
- 'lions': 'lionsRoute',
- 'tigers': 'tigersRoute'
- },
- showGenericRoute: function() {
- this.navigate("#/animals", { replace: true });
- },
- tigersRoute: function() {
- this.showGenericRoute();
- // handle the tigers route
- },
- lionsRoute: function() {
- this.showGenericRoute();
- // handle the lions route
- }
- routes: {
- 'animals/:animal': 'animalsRoute',
- },
- animalsRoute: function(animal) {
- // removes the animal from the url.
- this.navigate("#/animals", { replace: true });
- // use the chosen animal
- var view = new AnimalView({ type: animal });
- }
- var Router = Backbone.Router.extend({
- routes: {
- 'animals': 'animalsRoute'
- },
- animalsRoute: function() {
- // handle the generic behavior.
- }
- });
- var PussyRouter = Backbone.Router.extend({
- routes: {
- 'lions': 'lionsRoute'
- // ...
- },
- lionsRoute: function() {
- // handle lions, then redirect
- this.navigate("#/animals", { trigger: true, replace: true });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement