سؤال

In my EmberJS application, there are use cases where I want to observe something like '@each.score.votes', to calculate total votes or to return a sorted list etc.

'@each.score' is another Ember Object.

However, any observer (or computed property) trying to observe '@each.property.another_property' doesn't fire at all. See this http://jsfiddle.net/jqTRu/2/

Click 'Change Votes' to change votes, but total_votes is not re-computed. However, upon adding a person, it does fire.

Is this a bug, or is there a more sensible way to achieve what I intend? Thanks.

EDIT: Peter's pointed out that it's a bug. Christopher's fix works (as you can see here http://jsfiddle.net/kazim/jqTRu/3/).

هل كانت مفيدة؟

المحلول

This has to do with setting up a chained observer with '@each' in the path. Basically, what's happening is that you have a nested array situation, since '@each.property' is evaluated as an array.

'@each.property.@each.some_other_property' should work.

نصائح أخرى

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top