I wanna do something like a progress bar, which will be controlled by ember. So in my eyes, there are two and a half ways to achieve this:
-
Have an observer in the controller, which sets the elements’
widthwhen triggered. Problem: AFAIK, one can’t access DOM-elements from within the controller, i.e. like the way you’d do it in the viewthis.$('#progress'). -
Have an observer in the view, which observes the controller’s property. Problem: I don’t know, how to observe (and access) a controller’s property.
-
(bind the controller’s property via
{{bindAttr}}to a freakydata-progress="42"attribute and adjust the elementswidthwhenever the attribute’s value has changed)
Option 2 is your best bet.
Ember will set a view’s controller property when the view is created, you can use that to access the controller’s property.
I’ve posted a working example here: http://jsbin.com/hitacomu/1/edit