在 Ember JS 中选择动态创建的复选框
Selecting dynamically created checkboxes in Ember JS
您好,我正在从我的服务器端模型中提取数据并通过复选框填充它们。
如何获得复选框的用户选择?
我知道 this.get('isChecked')
可以获得复选框的值,但是在我的用户案例中我该如何做,因为可变数量的复选框将被动态填充?
注意:我没有使用 Ember 数据并通过 Ember.$.JSON() 从我的路由器调用我的服务器 API 来填充模型class.
我尝试按照此处给出的示例进行操作 Dynamically Create Inputs with Ember (and retrieve their values)
这里 EmberJS - Checkboxes and Getting Values in Controller
但是 none 似乎对我有用。
品牌模型有一个选中的布尔属性,默认情况下选择为 false。
{{#each brand in model}}
<div class="col-lg-2 col-xs-4">
<div class="brand-select-image-container">
{{input type="checkbox" name=brand.brand_name checked=brand.checked class="brand-select-checkbox" }}
<img src="http://localhost:3000{{brand.img_location}}" class="brand-select-image"/>
</div>
<p class="brand-select-name">{{brand.brand_name}}</p>
</div>
{{/each}}
好的,我为那些在弄清楚如何使 ember 复选框工作时遇到困难的其他人修复了它
this.get('model').forEach(function(item){
console.log(item.checked);
});
您好,我正在从我的服务器端模型中提取数据并通过复选框填充它们。
如何获得复选框的用户选择?
我知道 this.get('isChecked')
可以获得复选框的值,但是在我的用户案例中我该如何做,因为可变数量的复选框将被动态填充?
注意:我没有使用 Ember 数据并通过 Ember.$.JSON() 从我的路由器调用我的服务器 API 来填充模型class.
我尝试按照此处给出的示例进行操作 Dynamically Create Inputs with Ember (and retrieve their values) 这里 EmberJS - Checkboxes and Getting Values in Controller 但是 none 似乎对我有用。
品牌模型有一个选中的布尔属性,默认情况下选择为 false。
{{#each brand in model}}
<div class="col-lg-2 col-xs-4">
<div class="brand-select-image-container">
{{input type="checkbox" name=brand.brand_name checked=brand.checked class="brand-select-checkbox" }}
<img src="http://localhost:3000{{brand.img_location}}" class="brand-select-image"/>
</div>
<p class="brand-select-name">{{brand.brand_name}}</p>
</div>
{{/each}}
好的,我为那些在弄清楚如何使 ember 复选框工作时遇到困难的其他人修复了它
this.get('model').forEach(function(item){
console.log(item.checked);
});