Reputation: 305
I want to start some css transition when my page is fully loaded(including all background images), so I am trying
didRender
event of a component but its never getting called.This is how my codes look like
export default Ember.Component.extend({
didRender() {
console.log('did render working');
var home =$('#main-outlet')[0];
home.className += " homePage";
startTimer(5);
},
willDestroyElement() {
console.log("destroying view");
var home = $('#main-outlet')[0];
home.className = " wrap";
}
});
However,when I use didInsertElement
event my code works fine but I cant use as it is executed before getting loading the images itself
Any idea or an alternative approach on this?
Upvotes: 0
Views: 1096
Reputation: 6221
Try this:
didInsertElement() {
this._super(...arguments);
Ember.run.scheduleOnce('afterRender', this, function(){
var home =$('#main-outlet')[0];
home.className += " homePage";
startTimer(5);
});
},
didRender
works everytime after re-render. Maybe you should prefer didInsertElement
(that works only once) and schedule your function.
About: Ember Run
Upvotes: 1