Don't mind that this code uses full paths and other things. Those will change!
I have this controller code:
App.ProductsOneController.reopenClass({
product: {
images: []
}
});
Then a view which has this in its template:
{{#each image in App.ProductsOneController.product.images}}
<li class="small-image">
<img src="{{unbound image}}-small.png" />
</li>
{{/each}}
What I want to do, is display a list of images which updates according to the content of the images array.
And when I do something like this:
imageUrl = response.data.folder + response.data.imagedId;
tempImages = Ember.get(App.ProductsOneController, "product.images");
tempImages.unshift(imageUrl);
Ember.set(App.ProductsOneController, "product.images", tempImages);
Nothing happens. The view is not updated.
If I navigate away, and then return to this same state (we're talking only pushstate here) the view is updated.
I have tried to change the value from the console. When I set it to []
, then all images disappear as desired. If I try to set it to a non-empty array, sometimes it works, sometimes it gives me a type error, mentioning a undefined childView.
App.MyClass = Ember.Controller.extend()
is the declaration, thenApp.myClass = App.MyClass.create()
is the instantiation. – sly7_7