Markus Benz
Markus Benz

Reputation: 146

ember-data and get function to dig into async models is not working

i prepared a jsfiddle sample: https://jsfiddle.net/6Evrq/503/

I get a ember-data model "RegisteredFighter" and want to access on that model the "RegisteredFighter" property.

then i get an object with and all the other ember-data properties:

{
id: "3"
_data: {
    id: 3,
    Fighter:  3,
    FightRule:  1,
    WeightClass: 1,
    FightClass: 1
}
}

in the example: this.get("item") works fine

this.get("item").get("Fighter") returns unknown
this.get("item").get("Fighter").get("Name") returns unknown

In the handlebar template i can access the Birthday of a Fighter easily. Why not per script ? Is this a problem on my side or from ember-data???

Accessing it per:

this.item.store.find('Fighter', 3).then(function(data) {
    alert(data.get("Name"))
});

works fine to per script.

Please help!

Kind Regards Markus

Upvotes: 0

Views: 40

Answers (1)

Jakeii
Jakeii

Reputation: 1273

The component is rendered before all the data is loaded in, so inside didInsertElement the data won't be loaded in yet.

Upvotes: 1

Related Questions