Problem with template rendering


#1

Hello everyone.

I’m trying to render my template with articles (blog posts) on my main page, doing it this way:

App.IndexRoute = Ember.Route.extend({
renderTemplate: function () {
    this.render('articles');
  }
});

Well, it’s rendering ‘articles’ template, but this doesn’t calling (firing) a model: function() {...} hook in App.ArticlesRoute, so it doesn’t loading a “model data related” part of template.

Please help me how can I render all the template from another route?


#2

The render method in the route does not invoke the passed template’s route. In this case, it will render your articles template into the default outlet.

You’re still responsible for setting up the model in your index-route for your articles template.

Example with Ember Data:

App.IndexRoute = Ember.Route.extend({
  model: function() {
    return this.store.find('article');
  },

  renderTemplate: function () {
    this.render('articles');
  }
});