Suppose I have got a given ember application
App = Ember.Application.create()
A router
App.Router.map(function() {
this.resource("posts", function() {
this.resource("post", {
path: "/:post_id"
})
});
});
How do I execute a function each time whenever the application enters a given /:post_id ?
You can implement App.PostRoute to specify your custom behavior for your post route. If you don't, Ember will create this class behind the scenes.
The activate hook is called on the route every time the route is activated.
Example:
App.PostRoute = Ember.Route.extend({
activate: function() {
doSomething();
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With