AyKarsi
AyKarsi

Reputation: 9685

Ember.js pre4 multiple nested routing

In ember.js pre 4 I'm trying to achieve a routing which responds to the following routes (among others):

/contact/[id]
/contact/edit
/contact/new
/contact/list
/contact/list/my
/contact/list/team
/contact/list/groups

The first routes (up to list) I can manage: The variants of list (my/team/groups) is where I'm struggling. I just get a: "No route machted the URL '/contact/list/my' error when calling it.

I've tried multiple variations on how to achieve this kind of nesting. This is my current attempt:

    App.Router.map(function()
    {
        this.route("index");

        this.resource("contact", function(){
            this.route('new');
            this.route('show', { path: "/:contact_id" });
            this.route('edit', { path: "edit/:contact_id" });
        });

        this.resource("contact.list", function(){
            this.route("index");
            this.route("my");
        });


    });

Looking at the App.Router.router.recognizer.names: I see the following output:

contact.edit: Object
contact.index: Object
contact.list.index: Object
contact.list.my: Object
contact.new: Object
contact.show: Object
index: Object
__proto__: Object

Any ideas?

Upvotes: 3

Views: 585

Answers (1)

AyKarsi
AyKarsi

Reputation: 9685

This seems to work for me:

    App.Router.map(function()
    {
        this.route("index");

        this.resource("contact", function(){
            this.route('new');
            this.route('show', { path: "/:contact_id" });
            this.route('edit', { path: "edit/:contact_id" });
            this.resource("contact.list", { path: "list/" },function(){
                this.route("index");
                this.route("my");
            });
        });
    });

Upvotes: 2

Related Questions