0

In my application there are 3 routes as defined below everything is working properly but when then the route which is not defined is called, the blank page is displayed. like, if i enter url http://example.com/page.php/#invalidRoute then i got empty page i want to load "profile" view if no route is found, my code is given below....

ProfileRouter = Backbone.Router.extend({
    initialize : function() {},
    routes : {
        '' : 'profile',
        'detailedProfile' : 'detailedProfile',
        'moreReviews' : 'moreReviews',
    },
    profile : function() {
       /*Load a profile*/
    },
    detailedProfile : function() {
        /*Load detail profile*/
    },
    moreReviews : function() {
        /*Load more review*/
    }
});

thanks in advance...

Jitesh Tukadiya
  • 1,269
  • 1
  • 11
  • 25

1 Answers1

1

You can do something like this. The last route will match everything else that the other routes didn't fulfill. The order of the routes also matters in this case.

routes : {
    '' : 'profile',
    'detailedProfile' : 'detailedProfile',
    'moreReviews' : 'moreReviews',
    '*invalidRoute' : 'profile' /* catch all route */
}
Dennis Rongo
  • 4,611
  • 1
  • 25
  • 25