So I have an each loop that iterates over an ember model:
{{#each model.product.variants as |variant|}}
{{input type="radio" value=variant.id name="product_id" action="radioChecked" on="focus-in"}}
{{/each}}
What im trying to do is set the value of each input to the id
of the variant
, this part right here value=variant.id
. now this seems like it works because this is an example of the HTML being rendered:
<input id="ember821" name="product_id" type="radio" value="34">
I removed the extra ember classes from the above input to make it fit in one line.
Now what I'm trying to do is when the form is submitted grab the value of the radio button that is checked. what I did is give the radio button an action, action="radioChecked" on="focus-in"
and I try to set a product
property on my controller. here is my controller:
export default Ember.Controller.extend({
selectedProduct: null,
actions:{
radioChecked: function(){
console.log('action worked');
this.set('selectedProduct', value);
}
}
});
I get the error that value is undefined. How should I go about this?
Aucun commentaire:
Enregistrer un commentaire