2015-06-14 66 views
0

嗨我从我的服务器端模型中提取数据并通过复选框填充它们。 如何获取用户选择复选框? 据我所知,this.get('isChecked')可以让我的复选框的价值,但我怎么做我的用户情况下,因为可变数量的复选框将动态填充?在Ember中选择动态创建的复选框JS

注意:我不使用灰烬数据和填充通过模型中的灰烬$ JSON()从我的路由器类打电话到我的服务器API。

我尝试以下这里Dynamically Create Inputs with Ember (and retrieve their values) 这里EmberJS - Checkboxes and Getting Values in Controller 但他们都不是工作,我给出的例子。

品牌车型具有被默认选中为假一查布尔属性。

{{#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}} 

回答

0

好吧我固定它为别人谁是有一个艰难的时间搞清楚如何让烬复选框工作

this.get('model').forEach(function(item){ 
    console.log(item.checked); 
    });