In the code below, I visualize 3 views. The second and third views display App.controller.a . Clicking on the first view changes App.controller.a . When you click, the third view updates its contents. The second view does not update its contents. Why?
I assumed that the second view binds to the array App.controller.a . It seems that the binding is not updating.
Demo: http://jsfiddle.net/kcmH4/
The code:
App = Ember.Application.create({}); App.controller = Ember.Object.create({ a: Ember.A([1]), my_method: function() { var a = this.get('a'); $.each([2], function(i, element) { a.pushObject(element); }); } }); App.MyView = Ember.View.extend({ click: function() { this.get('content').my_method(); } });
Template:
{{#view App.MyView contentBinding="App.controller"}} First view: Click me {{/view}} {{#view Ember.View contentBinding="App.controller"}} 2nd view: {{content.a}} {{/view}} {{#view Ember.View contentBinding="App.controller"}} Third view: <ul> {{#each content.a}} <li>{{this}}</li> {{/each}} </ul> {{/view}}
hekevintran
source share