How can i check wether an outlet is already connected in my application template? In renderTemplate() I want to check wether the outlet actually needs to be connected or not (for performance reasons). The final code should look something similar to this:
renderTemplate: function(controller, model) {
var isMyOutletConnected = //how to do that?
if(!isMyOutletConnected){
this.render('someTemplate', { // the template to render
into: 'application', // the template to render into
outlet: 'someOutlet', // the name of the outlet in that template
controller: "someController" // the controller to use for the template
});
}
}
I tried to use the container to lookup the application view via: container.lookup("view:application)
but this instantiated a new view instead of returning the existing one.
Thanks for your input. This is the solution i came up with:
1 – Creating a view registry for my singleton views. View registry resides in the Application instance and its properties are set by the views in didInsertElement.
2 – Now i can access this registry to check for connected outlets in my routes:
This solution could be more generic, since the method “isOutletOfApplicationViewConnected” is hardwired to my application view, but this is a good beginning and works for me.