Reputation: 7230
I want to execute a simple action when the DOM is ready. I tried to use on('init')
but it's triggered before the template is loaded. I saw some options for components but I don't use a component.
Here is the code I have :
export default Ember.Route.extend({
onTemplateLoaded: function() {
console.log('message')
}.on('init')
})
Very simple. My question is basic but I don't find the solution. Can you help me?
Upvotes: 1
Views: 34
Reputation: 37075
Depends on what you're trying to do. If you want to do something on a particular route you'd currently end up with views/index.js
export default Ember.View.extend({
didInsertElement: function(){
this._super();
this.$().append("<h1>hi</h1>");
}
});
See: http://emberjs.jsbin.com/kegere/2/edit?html,js,output
Upvotes: 1