I am trying to create a Router for backbone, and I want to write it as a class with es6, so I have come up with this as a test:
class MyRouter extends Backbone.Router {
constructor() {
super(arguments);
}
routes = {
"*path": "error"
}
error(path) {
console.log("in myRouter error")
this.trigger("component", {
content: require("./error404/")(path)
});
return this.setRoute("error");
}
}
module.exports = new MyRouter();
However for some reason it is not recognized by Backbone, so the question is, am I missing something? Do I have to tell backbone to use my specific router?
Turns out the error was quite simple. You need to call super with the routes, i.e.