How do I set a property on an itemController?


#1

I have an ArrayController that uses associated itemControllers to track a checked property on the set of models (i.e. whether or not their checkbox is checked).

This part is currently working fine. When I come back to the route, I need to use some information off of the user model to “remember” which were checked.

How can I set the checked property on the specific itemController's? I can get references to the individual models that need “checking”, but model.set('checked', true) doesn’t seem to get picked up by the itemController in that scenario.

Any help would be appreciated!

P.S. I’m trying to set this from the route.


#2

I’ve figured out a way to do it by accessing the itemControllers as controller.get('_subControllers'). But I feel like someone is going to tell me I shouldn’t be doing that.


#3

http://jsfiddle.net/NQKvy/1043/

Yeah, that’s wrong. You have access to all your favorite array functions on the ArrayController that will let you filter, enumerate, through the underlying controllers w/o accessing _subControllers.


#4

Thanks @jasonmit! I think the issue was that I was trying to do operations on the content, rather than the controller. i.e. controller.get('content').forEach(function()..... rather than controller.forEach(function.....