1

I have a template called new, which has some input helpers to submit a new Request (subject and body). After them I have a named outlet tags, which should display a list of possible services we can add to the request (tags: fix, purchase, etc).

The problem is that when I navigate to new, only static data is displayed from the tags template ("inside tags template" would be displayed), but the #each does not loop at all.

If I add tags as a new resource into new, and navigate to new/tags, then the tags template would be rendered into both outlets of the new template ({{outlet}} and {{outlet tags}}, so my code is not faulty when it comes to displaying data, its just faulty when it comes to displaying it where and when I want to (only inside the new route).

Also, both my routes' models have a console.log message saying which route is accessed, and when I go to new only the new route displays a message.

I believe new does not know that it is supposed to use the tags controller, but I am clueless when it comes to Ember... (I do not want to get the tags via the new route, I want to use the tag route)

export default Ember.Route.extend({
model: function(){
    console.log("in new");
},
setupController : function(controller, model){
    controller.set("model", model);
},

renderTemplate: function() {
    this.render();
    this.render('tags', {
        outlet: 'tagO',
        into: "new",
        controller: 'tags'
    });

}

});

Dejan Biljecki
  • 595
  • 1
  • 5
  • 26
  • The example in the code block before the last code block in [this guide](http://emberjs.com/guides/routing/rendering-a-template/) uses `controllerFor` to get the reference of the controller. Have you tried that? Also, just in case, try also `requests/tags` if your controller is in nested folders. – MilkyWayJoe Sep 08 '14 at 15:50
  • Both files are in the same folder, and I already tried controllerFor... – Dejan Biljecki Sep 08 '14 at 15:57
  • i think you're passing the wrong parameter to `into`.. You're passing the same template you're trying to insert into... I *think* it should be the name of the template where the outlet `tagO` is defined, which I suspect it would be `request`? – MilkyWayJoe Sep 08 '14 at 16:08
  • no, there are just the new and tags templates, tags should be rendered into new's {{outlet tag0}} – Dejan Biljecki Sep 08 '14 at 16:20

1 Answers1

1

It's easier to just type {{render 'tags' someModel}} from the template than to programmatically do it in the renderTemplate hook and named outlet. You need to make the someModel available on the controller that you are currently in.

You'll want to hook up multiple models on the controller, see: EmberJS: How to load multiple models on the same route?

Example: http://emberjs.jsbin.com/OxIDiVU/1051/edit

Community
  • 1
  • 1
Kingpin2k
  • 47,277
  • 10
  • 78
  • 96