controllerFor from route and render

Why is the content of a controller retrieved from the route empty?

I’ve made the following JSBin to demonstrate what I want to do: http://emberjs.jsbin.com/ciduv/4/edit

So I’m rendering a template using {{render ‘detail’ model}} and from the route I’d like to get to the controller to later on set an ‘editing’ flag.

But content (as well as model?) is empty on the controller, therefor you can’t set properties directly.

Any suggestions?

Cheers, Tom

Since you have {{render}} inside of a loop you have multiple instances of DetailController, one for each item. That makes controllerFor() not behaving the way you expect.

You could do it the other way around and have a selected property on your parent controller (IndexController in this case) and have your DetailController check if it’s item is the selected one, and also set it as the selected item on an edit action or similar.

I made an example here: http://emberjs.jsbin.com/vulex/2/edit

Ah yes, mainly you mentioning the “multiple instances of” did the trick and caused me to re-read (again!) the docs: http://emberjs.com/guides/templates/rendering-with-helpers/#toc_the-code-render-code-helper

In my case a singleton controller should do the trick, as I will only have one instance on screen (I wanted to isolate the code/template). So I shouldn’t pass a model basically.

Thanks a lot!