Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I see absolutely nothing wrong with your approach. The <code>needs</code> is more about a controller relying on another controller, and what you appear to be doing is simply setting the <code>content</code> of an <code>Ember.ArrayController</code>. You'll need to change your implementation slightly to accomodate for <code>this.controllerFor</code> being <strong>@deprecated</strong> in Ember pre 5, but you can achieve this by:</p> <ul> <li>Specifying that the <code>PostsController</code> (and I assume others) require the <code>RevealController</code> using <code>needs</code>;</li> <li>Passing through the instance of <code>RevealController</code> to your <code>openModal</code> event (<code>{{action openModal this controllers.reveal}}</code>).</li> </ul> <p>There are of course other ways to achieve roughly the same thing. However, the advantages I see are as follows:</p> <ul> <li><a href="http://en.wikipedia.org/wiki/Dependency_injection" rel="nofollow">You're using dependency injection</a> in your events, which is great for testing, etc...;</li> <li>Your <code>App.ApplicationRoute</code> doesn't have the responsibility of having to find a controller;</li> </ul> <p>With one disadvantage is that you're going to pass around the <code>RevealController</code> in a handful of controllers that are able to invoke Reveal. I don't particularly see this as a disadvantage though, because if you find yourself specifying the <code>needs: ['reveal']</code> a <strong>lot</strong>, then you can always create an abstract controller which your <code>ArrayController</code>s extend, since <code>needs</code> is a concatenated property (see <code>concatenatedProperties</code> in Ember's <code>Ember.ControllerMixin</code>):</p> <pre><code>App.AbstractController = Ember.ArrayController.extend({ needs: ['reveal'] }); App.PostsController = App.AbstractController.extend({ // Since needs is a concatenated property, PostsController will have // access to 4 controllers: reveal, another, andAnother, andYetAnother. needs: ['another', 'andAnother', 'andYetAnother'] }); </code></pre> <p>What do you think to this?</p> <p>Also, the only non-Ember code you're really using that I can see is: <code>$('#myModal').reveal();</code>. Is there not a way in which you can place the Reveal code into the <code>didInsertElement</code> of the <code>App.RevealView</code>? And then in there you can do something like: <code>this.get('element').reveal();</code> or similar <em>(perhaps a sub-view?)</em>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload