Javascript 给输入一个动态值emeberjs
所以我有一个遍历余烬模型的each循环:Javascript 给输入一个动态值emeberjs,javascript,ember.js,ember-cli,Javascript,Ember.js,Ember Cli,所以我有一个遍历余烬模型的each循环: {{#each model.product.variants as |variant|}} {{input type="radio" value=variant.id name="product_id" action="radioChecked" on="focus-in"}} {{/each}} 我想做的是将每个输入的值设置为变量的id,这部分就在这里value=variant.id。现在这似乎是可行的,因为这是一个呈现HTML的示例: &l
{{#each model.product.variants as |variant|}}
{{input type="radio" value=variant.id name="product_id" action="radioChecked" on="focus-in"}}
{{/each}}
我想做的是将每个输入的值设置为变量的id
,这部分就在这里value=variant.id
。现在这似乎是可行的,因为这是一个呈现HTML的示例:
<input id="ember821" name="product_id" type="radio" value="34">
我得到的错误是值未定义。我应该怎么做呢?值已传入,因此需要在函数定义中定义
function(value){
console.log('action worked');
// note this will just be the id, you may want to query your collection
// and use the object instead of the id...
this.set('selectedProduct', value);
}
function(value){
console.log('action worked');
// note this will just be the id, you may want to query your collection
// and use the object instead of the id...
this.set('selectedProduct', value);
}