Skip to content

Instantly share code, notes, and snippets.

@ppcano
Created January 12, 2012 16:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppcano/1601668 to your computer and use it in GitHub Desktop.
Save ppcano/1601668 to your computer and use it in GitHub Desktop.
View get notified when its childviews has been inserted.
ScrollMixin = Em.Mixin.create({
didInsertElementEnd: function() {
this._setup_dimensions();
this._super();
}
..........
});
Em.View.reopen({
didInsertElementEnd: Ember.K,
invokeRecursively: function(fn, end) {
fn.call(this, this);
this.forEachChildView(function(view) {
view.invokeRecursively(fn, end);
});
if ( end ){
end.call(this, this);
}
},
_notifyDidInsertElement: function() {
this.invokeRecursively(function(view) {
view.didInsertElement();
}, function(view) {
view.didInsertElementEnd();
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment