{{control}} inside {{each}} is broken #1990

ahawkins opened this Issue Feb 5, 2013 · 10 comments

7 participants


Here's a completely feasible use case: you have an array that needs to be rendered as controls. You write this template:

{{#each widgets in controller}}
  {{control "widget" widget}}

The problem is the same controller is used for every widget. Passing in a different controlID option each time solves this problem. Perhaps controlID should be path that we can we make it a CP on the view or on the controller.

Edit: I've provided a fiddle http://jsfiddle.net/twinturbo/cH27A/. Seems it's more related to ArrayProxy then each. A loop of simple Ember.Objects works correctly.


I noticed the same thing and was able to get it working by registering the controller as a singleton right after Ember.Application.create.

Reader = Ember.Application.create({});
Reader.register('controller:index_image', Reader.IndexImageController, {singleton: false });


Also {{control}} inside {{collection}} has the same problem. @schmidp solution works great!


@emvu @schmidp the other solution is a unique controlID for everything. Either way, this is a bug and a common use case--or perhaps a misuse case. @wycats / core team needs to chime in on this one.


I tried to set controlID when using {{control}}, doesn't work for me, I still have this issue.

{{#each widgets in controller}}
  {{control "widget" widgets controlID="{{widget.id}}"}}

Is there something wrong with my source code?
Besides that, setting the controller as not being a singleton works well.

Ember.js member

Is there any other workaround for this?


+1 any work around? Additionally, how do you properly set the flag so you can use control?


Thanks @schmidp that let me be able to start using it and see the problem as mentioned above.

I wish there was more information about how to do reusable views. I've seen two potential options (control and view) but I can't get anything to work.


I was able to use the singleton solution to solve it. I do hope there will be better options in the future.

@wycats wycats closed this Feb 28, 2013

My workaround does not seem to work anymore.

I think {{control}} should support non singleton controllers as {{render}} does, but I don't think I know enough about ember.js to implement this.

@wycats: do you have some insights or plans with {{control}} regarding this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment