In a method on an Ember.View subclass, I would like to make changes to the DOM only if the view element has already been inserted into the DOM. How can I check that?
I know I could create an auxiliary property like so:
didInsertElement: function() {
this.set('elementIsInserted', true);
}
willDestroyElement: function() {
this.set('elementIsInserted', false);
}
But is there some canonical, built-in way?
I didn’t find anything skimming view.js, but perhaps I’m missing something.
If you want to avoid having to set an auxiliary flag, you can extend Ember.View:
Now every View that extends Ember.View will get the above.
Also a member of the core team suggested that you avoid referring to
inDOMas it is an internal variable and not intended to be used in code.