Where I should run business logic on transitionTo in Ember.js -


I have two different views:

  1. List of posts
  2. List of comments related to a particular post

When I click on the special post in # 1 view, I'm displaying the # 2 view using a simple transition ('Comments ', Post). What I want to do, all comments associated with the post are read, when they are shown. Suppose I want to run the method: markAllAsRead (comment) where should I put this business logic?

The ideal load will need to add some hook to the controller. Nothing like this can be found, the init method is called on the first load of only # 2 footage.

I can run it in the setup also in the controller

  App.IndexRoute = Ember.Route.extend ({setupControler: Function (controller, model) {this._super (controller, model); markAllAsRead (model);}});  

But this router does not design such a logic.

You can always add your initial function to your controller, and set the control function < Code> controller.initializeComments , for example, and the Setup required by the Administrator is complete each time the path is completed.


Comments