larryzhao
larryzhao

Reputation: 3213

Emberjs - Why view.element is undefined

Guys,

I am new to Emberjs, now trying Ember 1.0.0 out.

But I am confused that when I create a new View, and then append it to body, and in didInsertElement, view.element returns undefined which I expect to be an element.

I went a little bit into the source code, and try using view.currentState.getElement(view), and it returns the element correctly.

Why is that? Did I do something wrong?

Upvotes: 2

Views: 575

Answers (1)

Dinesh Kumar DJ
Dinesh Kumar DJ

Reputation: 488

You have to get the element from this object like this,

didInsertElement: function() {
   console.log(this.get('element')); //logs the element
}

Upvotes: 1

Related Questions