Skip to content
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

Embedded associations need special handling in Model.dataDidChange #248

Merged
merged 2 commits into from
Jun 21, 2012

Conversation

ghempton
Copy link
Member

@ghempton ghempton commented May 8, 2012

This is a fix for #218.

@envone
Copy link

envone commented May 9, 2012

+1, I have made similar code, seems clean.

@mixonic
Copy link
Sponsor Member

mixonic commented May 10, 2012

Oh +1 +1! I spent too much time hung up on this. I've got something like this locally:

https://github.com/mixonic/data/compare/read_embedded_has_many_association_from_data_on_parent_data_update

But this code looks better, and tested.

@guilhermeaiolfi
Copy link

Hi @ghempton, I tried your changes and it's not fully working for me.
I have a simple form that lists the hasMany relationship records. Like in: Parent hasMany Children, so:

{{view Em.TextField valueBinding="Parent.FieldOne"}}
{{view Em.TextField valueBInding="Parent.FieldTwo"}}
{{#each Child in Parent.Children}}
   {{Child.FieldChild}}
{{/each}}

After change some data in Parent and commiting those changes. The each helper doesn't show any children anymore.

Here are the object I get before commiting:

__ember1338575163426: "ember1204"
__ember1338575163426_meta: Object
_super: undefined
get content: function (){return n(this,a)}
recordCache: Array[2]
set content: function (){this instanceof Ember.Object&&!this.isDestroyed}
store: i
type: App.Telephone
__proto__: Object

After commiting:

__ember1338575163426: "ember1204"
__ember1338575163426_meta: Object
_super: undefined
get content: function (){return n(this,a)}
recordCache: Array[0]
set content: function (){this instanceof Ember.Object&&!this.isDestroyed}
store: i
type: App.Telephone
__proto__: Object

See the recordCache property. I don't know what {{each}} uses to list the records but after commiting the recordCache is gone.

@guilhermeaiolfi
Copy link

The comment above should have been gone in #256, that was the changes I tested against.

@wagenet
Copy link
Member

wagenet commented Jun 21, 2012

I just committed a fix that handles part of what you did here. However, it looks like you also cover some other cases. Can you rebase this? Thanks!

@wagenet
Copy link
Member

wagenet commented Jun 21, 2012

I think this fix is better than mine. Will revert my change and pull this instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants