2015-06-14 68 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); 
    });