I'm trying to redirect /dashboard/ to /dashboard/reach/demographic if the url hits /dashboard/.
Problem is, I still get redirected to /dashboard/reach/demographic/ if I hit a subroute like **/dashboard/traffic.
What is the Ember way of doing this?
Here is my code:
(function() {
App.Router.map(function(match) {
this.resource('dashboard', function() {
this.resource('traffic', function() {
this.route('visits');
this.route('pageviews');
return this.route('duration');
});
return this.resource('reach', function() {
this.route('demographics');
this.route('over_time');
return this.route('devices');
});
});
return this.route('audience');
});
App.DashboardRoute = Ember.Route.extend({
redirect: function() {
return this.transitionTo('reach.demographics');
}
});
if (!App.ie()) {
App.Router.reopen({
location: 'history'
});
}
App.reopen({
rootUrl: '/'
});
}).call(this);
Implement redirect in DashboardIndexRoute instead of DashboardRoute.
App.DashboardIndexRoute = Ember.Route.extend({
redirect: function() {
return this.transitionTo('reach.demographics');
}
});
I created a jsbin example for you. Try:
http://jsbin.com/odekus/6#/dashboard/
http://jsbin.com/odekus/6#/dashboard/traffic
I also removed unnecessary return's from the code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With