nicholaides
nicholaides

Reputation: 19489

How can you tell if an Ember view's element is in the document?

How can you tell your Ember view's element has been inserted into the document?

My current method is to do:

if (this.$().length) {
  // ...
}

Upvotes: 2

Views: 712

Answers (1)

escalant3
escalant3

Reputation: 68

Another solution is checking the dictionary of views. If you have a view like:

var helloView = Em.View.create({
  elementId: 'hello'
});

You can do:

var myView = Ember.View.views.hello;

// Check if it is in the DOM
myView.get('state') === "inDOM";

// Check if it is visible
myView.get('isVisible');

Upvotes: 1

Related Questions