1

I know I must be missing something, but I created a simple test to exercise the use of the {{render "viewName" model}} helper and I'm having trouble with it.

It works well except that in the view's controller I don't have access to a model property as indicated by the Ember documentation. Instead the controller's model property remains undefined.

Here is the fiddle that shows the issue: http://emberjs.jsbin.com/misiyaki/6/edit

As you can see I tested the model in the index template, and it works well. But when the ViewAView is rendered, the associated ViewAController does not have the specified model set in it. I tested it in the view's init method and it is not set there either. It is as if I had not specified any models in the helper.

What am I missing?

Thank you!!

Edy Bourne
  • 4,229
  • 9
  • 42
  • 75

1 Answers1

0

the model's referred to as model within the template, not testModel that was just the type of model you wanted the store to find.

Additionally the controller needs to be an ObjectController if it's being backed an object.

App.ViewAController = Ember.ObjectController.extend

http://emberjs.jsbin.com/misiyaki/7/edit

Kingpin2k
  • 47,007
  • 10
  • 75
  • 96
  • Oh I see, but according to the docs (http://emberjs.com/guides/templates/rendering-with-helpers/) I can specify which model I want to use with the `{{render}}` helper, right? It refers to `{{render "author" author}}`, indicating the model by name. That's what I'm trying to do.. In this case I want to use a model different from the route's model. I just didn't define two of them, and was trying to call the same by name as the doc seems to suggest. Is this possible at all? To be in a context with model `A` and invoke the `{{render}}` helper to render `viewX` with model `B`? – Edy Bourne Jun 05 '14 at 14:26
  • OK, I understood this now. The model needs to be available in the context, which sucks. But with the workaround provided by http://stackoverflow.com/questions/16463958/how-to-use-multiple-models-with-a-single-route-in-emberjs-ember-data it is possible to have multiple, unrelated models in the same context so one could be passed to render. Thanks! – Edy Bourne Jun 05 '14 at 16:07