Coming from a Cocoa background, it feels natural to me to be able to have a reference to views and components in a controller.
Let’s say I have a component that has a method someMethod. I want to be able to trigger this from outside of the component (let’s say from a button on the same page). Is it possible to store a reference to the component in the controller, so that I can call this method? Or is this a big Ember anti-pattern?
I could extend this question by asking whether it is possible to reference specific DOM elements from a view or component.
I think having such a possibility opens up a lot of flexibility. Right now the only way I see to achieve such things is to use property bindings or using jQuery to select DOM elements.
The mantra these days is data down actions up. so your component should trigger some method based on a change in the data. If the component wants to change the data it fires an action up for whoever owns the data to handle. Also controllers are going away to be replaced with routable components, think component that a route is tied to. Views are basically deprecated in favor of components. You architect your application as a nested set of components that all fire actions up and observe data that was passed to them. You will be using bindings a lot, you can pretty much avoid jquery most of the time unless you’re integrating a third party lib. As further reinforcement for this architecture in 2.0 bindings will be one way. Hopefully that helps a bit.
or more hacky way; If you render each component with a static id e.g {{button id="saveProject"}} you can get access to it via Ember.View.views['saveProject'] and do whatever you want e.g. triggerAction etc