Is there any method to detect invalid (or undefined) route and trigger 404 page in Backbone.Controller?
I\'ve defined routes in my Controller like this, but it didn\
The above works, but I'm not sure why you have to do what you do in the constructor. It may be slightly brittle, but we create a separate controller that we include in last. Its last so that the splat route is the last one to match:
NotFound = Backbone.Controller.extend({
routes: {
"*path" : "notFound"
},
notFound: function(path) {
var msg = "Unable to find path: " + path;
alert(msg);
}
});
new NotFound();
Using a more robust version of the above seems a cleaner approach to me.