dimanche 1 février 2015

Ember loading values on controller load

I am attempting load an array of genres, for use as select values. Multiple selects can be created using an addSelect action. Here's how I load the data.



genreStrings: function() {
var array = [];
this.store.findAll("genre").then(function(genres){
genres.forEach(function(genre){
array.push(genre.get('combinedName'));
});
});
return array;
}.property(),


And then it's used in the template like so.



{{view "select" content=genreStrings value=genre.name prompt="Select a Genre" }}


The problem I face is that the first select that loads as the page loads has no values, whilst each subsequent one, added by using the addSelect action has the values as expected.


I have tried .on('init') but this still isn't working.


How can I get these values to be set for the first select?





Aucun commentaire:

Enregistrer un commentaire