I have two separate views:
When I click on particular post in #1 view I'm displaying #2 view using simple transitionTo('comments', post). What I want to do is to mark all comments connected with the post as read when they are displayed. Let's say I want to run method: markAllAsRead(comment). Where I should put this business logic?
The ideal would be to add some hook to controller on loading. Can't find anything like this, init method is called only on first load of #2 view.
I can also run this in router in setupController
App.IndexRoute = Ember.Route.extend({
setupControler: function(controller, model){
this._super(controller, model);
markAllAsRead(model);
}
});
But it router doesn't seems to be designed to keep such logic.
You could always add your own initialize function to your controller, and in your route's setupController function controller.initializeComments(model)
, for example, and perform your necessary setup from the controller every time the route is loaded.