lundi 16 novembre 2015

store.findAll strange behavior

I have next code in controller:

ingredients: function() {
    var self = this;
    this.store.findAll('ingredient').then(function() {
        var ingredients = self.get('model').get('ingredientsWithQuantities').map(function(item) {
            return {
                name: self.store.peekRecord('ingredient', item.ingredientId).get('name'), 
                quantity: item.quantity
            };
        });

        self.set('ingredients', ingredients);
    });
}.property('model.ingredientsWithQuantities')

It's computed property related to one of the routes. It's works fine if 'ingredients' model loaded somewhere earlier. But if it just loading first time, when then function called there is no data in the store.

I'm expecting that findAll should call then only after data will fetch. How can I handle with this?




Aucun commentaire:

Enregistrer un commentaire