I have a view with a {{#each}} loop. The collection on which I do the iteration containing data that loaded as the app starts, and additional data that loaded later (only after success on an Ajax call).
When the additional data arrives, using promises I add the data to the array. I use Ember.MutableArray so I could change the array and refrash the view when I do so. However the view contains helpers inside the #each loop. And after the additional data rendered the helpers aren't executed again and I'm stack with the plain html
Part of my code:
// HTML
{{#each item in array}}
<div>
<!-- This Helper will be displayed for all items,
except for the data from the Ajax call -->
{{my-helper item.imgUrl}}
</div>
{{/each}}
// JS
Ember.ObjectController.extend(
{
init: function()
{
var ctrl = this;
var data = ctrl.get('controllers.application.appData');
ctrl.array = Ember.A(data.array);
data.DataLoadedDefer.promise().then(function()
{
ctrl.array.unshiftObject(data.serverData);
});
}
});
So how can I reload the helper, or maybe refresh the whole view?
Aucun commentaire:
Enregistrer un commentaire