2

I am using the following configuration for my router:

var Router = Backbone.Router.extend({
            routes: {
                'item/:param(/:param-2)': 'func1',

                // Default
                '*actions': 'defaultAction'
            }
        });

I initialize the router as follows:

    var router = new Router;

    router.on('route:func1', function(param1, param2){
        console.log("Route: summary, class_id: " + class_id);

    });

But only URLs of the format #item/1 are matched by the func1 route.

URLs like #item/1/3 are passed to the defaultAction route.

I'm not able to figure out why the optional parameter doesn't get matched.

Deepak Joy Cheenath
  • 5,796
  • 5
  • 25
  • 29

1 Answers1

1

For others, the "-" character is not allowed in a parameter name. (Although it is allowed to be part of a route.)

You can replace "param-2" with "param_2" and it will work.

TheJoe
  • 256
  • 1
  • 8