Ember.js: Insert child resource view into main application

By default, Ember inserts the representation of the child resource into {{outlet}}that defined by the view of the parent resource. How do I override this? those. Insert a child view in the {{outlet}}defined view of the application. Why is this the default value?

Usecase: There is a resource userswith a route newinside it. I want it to newappear in applications {{outlet}}, not in the parent resource {{outlet}}.

App.Router.map(function(){
  this.resource('users', function(){
     this.route('new');
  });
});
+5
source share
1 answer

For each route, we have a method renderTemplatethat we can overload. This gives us full control over the rendering of views.

, , {{outlet}} into:

( , , .)

var UsersRoute = Ember.Route.extend({
    renderTemplate: function() {
        this.render('users', {
            // Render the UsersView into the outlet found in application.hbs
            into: 'application'
        });
    }
});

outlet:

var UsersRoute = Ember.Route.extend({
    renderTemplate: function() {
        this.render('users', {
            // Render the UsersView into the outlet named "sidebar"
            outlet: 'sidebar'
        });
    }
});

, , , , , into.

+14

All Articles