-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
belongsTo-relationship returning Ep.LazyModel #34
Comments
Can elaborate on how it never turns into one? Lazy models will load their underlying record once a property is observed/accessed. |
I will investigate into this more, but from what I saw it looks like even though the Lazy Model loads the record, the main binding for the relationship does not reflect the loading. Maybe some kind of property change notification is needed after |
It should automatically be updated. I'm not sure I fully understand what is happening here. Can you share some code? |
So, I have the following models: App.Foo = Ep.Model.create({
name: Ep.attr('string'),
bars: Ep.hasMany(App.Bar)
})
App.Bar = Ep.Model.create({
desc: Ep.attr('string'),
foo: Ep.belongsTo(App.Foo)
}) ... and the following view template for a Show Bar: {{desc}},
foo: {{foo}},
foo name: {{foo.name}} This renders like this: Show Bar: super bar,
foo: <Ep.LazyModel:ember123:(unloaded App.Foo):[1, foo1]>,
foo name: awesome foo So it seems that the attributes of the I think the best thing to do is to just notify all associations that the model changed (without the associations becoming dirty). Any ideas? Or am I just doing it wrong? |
What's the use case for explicitly knowing when an Ep.LazyModel is resolved? You should be able to treat it just the same as if it were the actual Ep.Model that it proxies. Then, when you try to access/observe one of it's properties, it will resolve without you having to worry about it. I haven't had any issues with the way it works, but it's certainly possible there is a valid use case I am missing. |
@jasonkriss you're right that this is only really an issue in special cases. For me this came up when I used an {{view Ember.Select
contentBinding="controller.foos"
valueBinding="foo"
optionLabelPath="content.name"}} In that case, selection is not properly handled, since the content is an array of |
This issue actually runs a little deep into Ember.js core. Ember has the notion of |
Not really an issue here any more. |
I'm not sure if this is a bug or just improper use on my side, but I have the problem that for a belongsTo relationship, the associated model never turns from an
Ep.LazyModel
instance to a proper (e.g.App.Foo
) instance.The JSON just serves the id, e.g.
{foo_id: 42}
.Any hints?
The text was updated successfully, but these errors were encountered: