Reputation: 556
I have an app route that takes an app id, from here I goto app/:app_id/settings, this opens a Twitter Bootstrap modal, from a separate template, from here I'd like to be able to do things like change the app name and other stuff like that but I can't seem to get access to that model. I assumed since I was nesting the routes I would have access to the current app model but I didn't. I also don't have access to the params in the parent route so not sure what to do. I've included the relevant (I think) code below.
WEM.Router.map(function(){
this.resource( 'apps', { path: '/' }, function(){
this.resource( 'app', { path: 'app/:app_id'}, function(){
this.resource( 'settings', { path: 'settings' } );
this.resource( 'error', { path: 'error/:error_id' } );
});
});
});
// Routes
WEM.AppsRoute = Ember.Route.extend({
model: function(){
return WEM.App.find();
}
});
WEM.SettingsRoute = Ember.Route.extend({
model: function( params ){
console.log( WEM.App.find( params.app_id ).get( 'id' ) );
return WEM.App.find( params.app_id );
}
});
Upvotes: 3
Views: 982
Reputation: 808
i think changing the model hook of your SettingsRoute
to
model: function(params) {
return this.modelFor("app");
}
might help.
Upvotes: 3