Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Bindings is a fundamental concept in Ember.js, so don't hesitate to use it :)</p> <p>Your example works if you create a binding for your <code>dependency</code>, see <a href="http://jsfiddle.net/pangratz666/Gqc7Q/" rel="nofollow">http://jsfiddle.net/pangratz666/Gqc7Q/</a>:</p> <pre class="lang-js prettyprint-override"><code>App = Em.Application.create({ VERSION: "0.1" }); App.dependency = Em.Object.create({ prop: [] }); App.View1 = Em.View.create({ dependencyBinding: 'App.dependency', name: "Foo", changeName: function () { this.set("name", "Bar"); }.observes("dependency.prop") }); App.View2 = Em.View.create({ dependencyBinding: 'App.dependency', name: "Foo", changeName: function () { this.set("name", "Bar"); }.observes("prop"), propBinding: "dependency.prop" }); // Updating the 'prop' property of dependency. dependency.get("prop").pushObject("An object."); </code></pre> <hr> <p><strong>UPDATE</strong></p> <p>The problem was that you are changing the contents of an array and not the array itself. So you have to change the observer path to <code>dependency.prop.@each</code>, see <a href="http://jsfiddle.net/pangratz666/3QccA/" rel="nofollow">http://jsfiddle.net/pangratz666/3QccA/</a>. But I don't know why it's working with the binding approach and not with this one... You should file a ticket on <a href="https://github.com/emberjs/ember.js/issues" rel="nofollow">GitHub</a>.</p> <p>As a last note, the above solution using bindings is the approach which is more Ember like ...</p> <pre class="lang-js prettyprint-override"><code>var dependency = Em.Object.create({ prop: [] }); App.View1 = Em.View.create({ dependency: dependency, name: "Foo", changeName: function () { this.set("name", "Bar"); }.observes("dependency.prop.@each") }); App.View2 = Em.View.create({ dependency: dependency, name: "Foo", changeName: function () { this.set("name", "Bar"); }.observes("prop"), propBinding: "dependency.prop.@each" }); // Updating the 'prop' property of dependency. dependency.get("prop").pushObject("An object."); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload