Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the recommended way to use a shared View in a template which needs a controller
    text
    copied!<p>We are using one of the later versions of Ember (router V2), not the bleeding edge with the even newer Router V2.2 (Last commit: 668783a (2013-01-06 21:10:55 -0800))</p> <p>In our solution we have several View components (Grid, autocomplete, search views etc.). Some of these components access the store, models etc. so they have a controller that handles that work. These views are used in several templates throughout our solution.</p> <p>In the old version (pre2) we used those view components like this:</p> <pre><code>App.ConsoleView = Ember.View.extend({ templateName: 'console', searchView: App.SearchView.extend(), ..... }) </code></pre> <p>And in the console template we used the common view like this</p> <pre><code>{{view view.searchView controllerBinding='App.searchController'}} </code></pre> <p>I have always felt that this approach is not the best way, and with the new version of Ember it has smacked us on our fingers :)</p> <p>Now to the question: 'What is the recommended way to use a shared View in a template which needs a controller.'</p> <p>In the newer versions of Ember the template expression</p> <pre><code>{{view view.searchView controllerBinding='App.searchController'}} </code></pre> <p>does not work because App.searchController is no longer instantiated at the App namespace.</p> <p>I have thought of some choices but really don't like them.</p> <ol> <li>I could connect the controller to the 'parent controller' through the router, but then I would have to do this in every route where I use a shared component, and that would be a lot.</li> <li>I could fetch the controller through some hacky way and set it through the init function in the views init function.</li> </ol> <p>Does someone have any recommendations on how to do this a good way? I cannot find any documentation on this, and have run out of googlejuize.</p> <p>All responses will be appreciated!</p>
 

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