Prasenjit Paul
Prasenjit Paul

Reputation: 61

TransitionTo is not working

I wanna create a transition, like, if someone goes to index or to /profile-details it will be redirected to /profile-details/preview. Here is my map and redirection code:

UserProfileApp.Router.map(function () {

                this.resource('profile', { path: '/' }, function () {

                    this.resource("personal", { path: "personal-details" }, function () {
                        this.route("preview", { path: "preview" });
                        this.route("edit", { path: "edit" });
                    });

                    this.route("loyalty", { path: "loyalty-membership" });

                    this.resource("passengers", { path: "passengers" }, function () {
                        this.route("new", { path: "new" });
                        this.route("passenger", { path: ":passenger_id" });
                    });

                    this.route("password", { path: "password" });
                });

            });

            UserProfileApp.ProfileRoute = Ember.Route.extend({
                beforeModel: function () {
                    this.transitionTo('personal');
                }
            });

            UserProfileApp.PersonalRoute = Ember.Route.extend({
                beforeModel: function () {
                    this.transitionTo('personal.preview');
                }
            });

If I remove any of the transitionTo, it works accordingly, but with both the transitionTo's in is not working

Upvotes: 0

Views: 1062

Answers (2)

wp_user
wp_user

Reputation: 138

In addendum to @Edu: You can also pass in an id which you want to transite to:

this.transitionTo('personal', eventualId);

Upvotes: 1

Edu
Edu

Reputation: 2520

Have you tried this?

        UserProfileApp.ProfileRoute = Ember.Route.extend({
            beforeModel: function () {
                this.transitionTo('personal');
            }
        });

        UserProfileApp.PersonalRoute = Ember.Route.extend({
            beforeModel: function () {
                this.transitionTo('preview');
            }
        });

Good luck

Upvotes: 0

Related Questions