jeudi 25 décembre 2014

How can I derive the content of my select view from records in ember?

I have this:



App.LoginRegisterController = Ember.ObjectController.extend({
init: function () {
this.set('products', this.store.find('product'));
},
subscriptionOptions: function () {
return this.get('products').map(function (product) {
return {id: product.id, title: product.title};
});
}.property('products')
});


Then in my template:



{{view "Ember.Select"
content=subscriptionOptions
optionValuePath='content.id'
optionLabelPath='content.title'}}


However subscriptionOptions only get called once before the products are populated. If I change the template to:



{{view "Ember.Select"
content=products
optionValuePath='content.id'
optionLabelPath='content.title'}}


The data gets populated correctly, but I need to insert an option into the select that isn't related to any of the models, so I need to populated it with references. How can I get the select to update from subscriptionOptions as products change?





Aucun commentaire:

Enregistrer un commentaire