I'm confused on how to manage global sections on the page that are not using a route, for example a notifications dropdown.
The notifications dropdown will always be visible and should update accordingly.
This is what I have tried.
Set the notifications on the ApplcationContoller
App.ApplicationRoute = Ember.Route.extend({
setupController: function(controller) {
controller.set('notifications', this.store.find('notification'));
}
});
And use them in the ApplicationTemplate
<script type="text/x-handlebars">
{{#each notifications}}
Message: {{message}}
{{/each}}
<script>
Although this works it doesn't seem right as I would like the notifications to at least have it's own controller.
So I couldn't figure out how to assign a controller to the notifications so I created a view for the notifications and tried assigning the controller that way, like this.
Created a view for the notifications
App.NotificationsView = Ember.View.extend({
controller: App.NotificationsController.create(),
templateName: 'notifications'
});
Created a notifications template
<script type="text/x-handlebars" data-template-name="notifications">
Notifications
</script>
Created the NotificationsController
App.NotificationsController = Ember.Controller.extend({
init: function() {
this._super();
this.set('content', this.store.find('notification'));
}
});
And I get the following error.
Uncaught TypeError: Cannot call method 'find' of null
Which is obviously saying that this.store
is null
So overall, what is the best way to achieve this sort of functionality?