Subject. Trying to do this:

var HellospaceRouter = Backbone.Router.extend({ routes: { "/": "root", "signup": "signup", "login": "login" } }); 

But the root router is not processed. At the docks on this subject nothing is said, alas.

1 answer 1

The default router has an index of '' (empty string):

 var Router = Backbone.Router.extend({ routes: { 'items/:id': 'itemDetails', '': 'root', }, itemDetails: function (id) { console.log('id: %o', id); }, root: function() { console.log('root'); } }); var router = new Router(); Backbone.history.start(); 
  • Strange. Works. I did it first too. And it did not work. I will think why. - ReklatsMasters
  • By the way, look at the updated fiddle, there is a demonstration where it indicates' / ' - zb'
  • I am interested in this. If I go to /, the content does not appear, and if I change the hash, too, but if I go, for example, to / # / login, the content is drawn. And even / # / corresponds to the main one. But on / does not respond as well. - ReklatsMasters
  • Does console.log () work? maybe you need to wait for DomReady? - zb '
  • Your example works, which is strange. I call it that way. - ReklatsMasters