Last active
December 11, 2015 23:28
-
-
Save noelrappin/4676370 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here's a description that is roughly the problem I'm having: | |
The ember.js site I'm working on has a number of different screens | |
(deliberately using a word that has no ember connotations). | |
Let's say, for the sake of argument, 3 of them. | |
Each of these screens has their own normal route, controller, model, | |
template structure. This is all standard. | |
Now I want a dashboard. For the sake of argument, let's say I want | |
the dashboard to show all three of the individual screens at the | |
same time, with exactly the same markup for each as you would get | |
if you viewed the screen individually. In other words, I basically | |
want the dashboard to defer to each of the three individual screens | |
to draw part of its dashboard. | |
Instinctively, I want my dashboard template to be something like this: | |
{{controller "MyApp.ScreenAController"}} | |
{{controller "MyApp.ScreenBController"}} | |
{{controller "MyApp.ScreenCController"}} | |
Where {{controller}} is a presumably mythical directive that defers to | |
a different controller. | |
What I wound up doing was more like this: | |
{{view "MyApp.ScreenAView"}} | |
{{view "MyApp.ScreenBView"}} | |
{{view "MyApp.ScreenCView"}} | |
Where I moved the logic from my existing controllers to views. However, | |
this has a drawback or two. For one thing, properties in the controller | |
that I might have previously referenced as {{visible}} now need to be | |
{{view.visible}}. Also, actions need to be explicitly targeted to the | |
view. It works, but feels fragile. | |
So, my specific question is, is there a better way to do this? My general | |
question is, what is the idiomatic Ember mechanism for splitting a | |
controller up into component parts -- the Guide entry on views implies | |
that splitting into component views is not the way to go, but I'm not sure what is. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I haven't really played with this sort of setup yet, but I think using the
render
helper in your main template might be what you're looking for.