EmberJS - Relationship not remotly pushed


#1

I have two model with a one to one relation. I only need one direction of the relationship.

App.A = DS.Model.extend({
    b: DS.belongsTo('b', { async: true }),
});

App.B = DS.Model.extend({
    name: DS.attr('string'),
});

Model A is load from the server. Model B is manually pushed using store.pushPayload.

If Model B is loaded before Model A, everything is fine and {{a.b.name}} works correctly inside the template. But when Model A is loaded before Model B, then the name is empty (the whole relation is not set actually).

How can I tell model A that model B was loaded?


#2

Would a.set('b', b) after pushPayload work? What have you tried so far?


#3

Sorry for the delay.

I don’t think a.set('b', b) should be necessary here because the relationship between a and b is specified in the definition of each a model.

I made a jsbin to explain better what I want to achieve. After 5sec, all B models are load and I would expect that the relation between A and B appears on the screen.

And you know what? It works but only inside the editor of jsbin (/edit at the end). Under this url http://emberjs.jsbin.com/coqidayuhi/1, within my App or locally on my computer (served with web server) Ember still fails to solve relationships.

Can someone explain me what is wrong here?