I have some jQuery code which needs to be run when a view is rendered. For the initial render I can easily do
App.FooView = Ember.View.extend({
didInsertElemen
If you would like to re-render the view when a certain attribute changes then what you want would look something like this:
App.FooView = Ember.View.extend({
myProperty: 'This value might change',
myPropertyChanged: function() {
//Do some stuff here (maybe change the template) and call...
this.rerender();
}.observes('myProperty')
});
But if you are looking to only re-render the view after the view is created then you want something more like this:
App.FooView = Ember.View.extend({
init: function() {
this._super();
//Do some stuff here (maybe change the template) and call...
this.rerender();
}
});
SOURCE: http://emberjs.com/api/classes/Ember.View.html
In addition to Akash's explanation, you would want to use the didInsertElement hook instead of the init hook to only re-render after the view is created. So it would look more like:
App.FooView = Ember.View.extend({
didInsertElement: function() {
this.rerender();
}
});
Although, I'm not exactly sure why you'd need to rerender after the view has already rendered.