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

CP based on model.hasDirtyAttributes not firing in ED 1.13.11 / E 1.13.10 #3737

Closed
zyllorion opened this issue Sep 9, 2015 · 6 comments
Closed

Comments

@zyllorion
Copy link

Currently have a model with numerous hasMany's, e.g.

myModel
--otherModel1
--otherModel2
--otherModel3

It is initialised in the pod route, and controller.set('model', model); so it is visible in the controller and template, which it is through the usual model.myModel.

When I create a CP with the structure;

isTreeDirty: Ember.computed([the conditions],
        function() {[return t or f based on status of related entities]

or

isTreeDirty: function() {
[return t or f]
    }.property([conditions])

where conditions are all combinations of;

model.myModel.hasDirtyAttributes
model.myModel.otherModel1.hasDirtyAttributes
model.myModel.otherModel1.[].hasDirtyAttributes
model.myModel.otherModel1.@each.hasDirtyAttributes
...

the CP does not fire when there is a change to the model or nested models. The change is visible in Ember Inspector.

This worked with the same ED 1.13 but Ember v1.12, and for the upgrade of this CP initially I added [] references which caused things to break, then on reverting to just the @each (first and last lines in list above) it worked again.

There doesnt seem to be an explanation of [] on http://guides.emberjs.com/v1.13.0/object-model/computed-properties-and-aggregate-data/

Any ideas? Thanks

@fivetanley
Copy link
Member

This worked with the same ED 1.13 but Ember v1.12

Does this mean it worked on Ember 1.11 but not 1.12?

@zyllorion
Copy link
Author

All but the [] example worked on 1.9 thru 1.12, the addition of a [] watcher broke the whole CP, I can't test if adding [] to Ember 1.12 breaks it as project is now migrated

@svox1
Copy link
Contributor

svox1 commented Sep 21, 2015

Same problem with Ember 2.0.2.

I cant bind:

model.myModel.@each.hasDirtyAttributes

We need the hasDirtyRelationships as mention at the Ember 1.13 release:
http://emberjs.com/blog/2015/06/18/ember-data-1-13-released.html
:)

@toovy
Copy link

toovy commented Oct 21, 2015

I found with Ember and EmberData 2.1.0 we cannot bind to ANY property with @each for hasMany relationships (in addition to the report from @svox1.). Won't work:

Book = DS.Model.extend
    pages: DS.hasMany 'page', async: true
    sorted_pages: Ember.computed 'pages.@each.idx', ->
        # resort, won't be triggered if any page idx changes

I believe that this worked once and I think this is a major bug. Happy to help if I can support. Any workaround appreciated.

Update: I'm now sure this once worked. We are currently upgrading from Ember 1.11.0 and EmberData 1.0.0-beta.15. In the old version the computed property subscribed to model.pages.@each.isDirty. A change of any attribute of the page affected the computed property. Now with model.pages.@each.hasDirtyAttributes this computed property never gets updated if any of the pages properties changes.

This is also an issue for observers, not only for computed properties.

@toovy
Copy link

toovy commented Oct 21, 2015

Related to emberjs/ember.js#12475

@bmac
Copy link
Member

bmac commented May 26, 2016

I believe this has been fixed in Ember by emberjs/ember.js#12908

@bmac bmac closed this as completed May 26, 2016
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

No branches or pull requests

5 participants