Adding a new route to an existing Ember.js app, need input -
i have existing ember app works great. need add new subroute app allow users view additional information. current route looks this:
social.router.map(function() { this.resource('accounts', { path: '/accounts' }, function(){ this.resource('account', { path: ':account_id'}); }); });
with following url
#/accounts/56/
the route i'd add this:
#/accounts/56/interactions
so added nested route so:
social.router.map(function() { this.resource('accounts', { path: '/accounts' }, function(){ this.resource('account', { path: ':account_id'}, function(){ this.route('interactions', { path: '/interactions'}); }); });
});
but when route accessed following error:
uncaught error: assertion failed: route interactions not found core.libs.js:2236 uncaught error: cannot modify child views while in inbuffer state core.libs.js:19298
so added empty interactionsroute didn't resolve it:
social.interactionsroute = ember.route.extend();
does have input on might going wrong?
in addition i'm trying add button interface looks this:
{{#linkto "interactions"}}@ interactions{{/linkto}}
social.router.map(function() { this.resource('accounts', { path: '/accounts' }, function(){ this.resource('account', { path: ':account_id'}, function(){ this.route('interactions', { path: '/interactions'}); }); }); });
like url interactions #/interactions
but wanted this: #/accounts/56/interactions therefore need remove preceding slash in path hook of interactions, otherwise you'll indicate route accessed root.
social.router.map(function() { this.resource('accounts', { path: '/accounts' }, function(){ this.resource('account', { path: ':account_id'}, function(){ this.route('interactions', { path: 'interactions'}); }); }); });
by way, if don't declare path hook url same route name. can use this:
social.router.map(function() { this.resource('accounts', function(){ this.resource('account', { path: ':account_id'}, function(){ this.route('interactions'); }); }); });
Comments
Post a Comment