samedi 6 octobre 2018

Ember this.get() is not retrieving property on component

Storing a Plain JS NodeList in an Ember component property, but when trying to access it in a function using either this.prop or this.get('prop') or get(this, 'prop') it only returns undefined.

I have console.log(this.prop) and I get the NodeList. Just retrieving it from within a function which is within the didRender() hook will not return the NodeList.

I must be missing something obvious, like I need to make this into an Ember Object first?

My steps:
1. In Ember component didRender() hook
2. Use plain JS using querySelectorAll('.my-class') -> returns a NodeList // working!
3. Add event listeners to Nodelist // working!
4. Set component property to NodeList value this.set('prop', Nodelist) // working!
5. Call event listener function outside didRender() hook // working!
6. In function (outside didRender() hook), attempt to retrieve variable using this.prop, or this.get('prop') or get(this, 'prop') and assign to variable. // NOT working!




Aucun commentaire:

Enregistrer un commentaire