Robert
Robert

Reputation: 816

backbone.js and routing

I'm not sure if either im doing something wrong, But I have a function in my router set up like so:

    ":page/"    : "page",
    ":page/:subpage"    : "subpage"

but if the user were to access :page without the forward slash my page function breaks. I've tried adding another function without the forward slash and it breaks it somehow.

  ie: ":page":"page"
      ":page/":"page"
      ":page/:subpage/":"subpage"

Upvotes: 3

Views: 192

Answers (1)

Nam Bok Inator
Nam Bok Inator

Reputation: 46

you can do the following to fix the issue:

var Router = Backbone.Router.extend({
      routes: {
      'page(/)': 'page',
      ":page:subpage(/)"    : "subpage"
    }
});

Upvotes: 3

Related Questions