hay I have a code for the radio button, the default checked code shows allbrand and I want to change the default checked to ncarbrand
this code component.hbs:
<div class="">
<div class="form-group">
<label>Kondisi</label>
<div class="input-group">
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-orange active" style="margin-bottom:0px;">
<input type="radio" name="condition" autocomplete="off" value="ncar">
Baru
Baru
</label>
<label class="btn btn-orange active" style="margin-bottom:0px;">
<input type="radio" name="condition" autocomplete="off" value="ucar">
Bekas
Bekas
</label>
</div>
</div>
</div>
</div>
this code component.js:
_filters: computed('filters', 'cart.contents.condition', function() {
let obj_brands_all = [],
obj_brands_new = [],
brands = get(this, 'filters.brand').split('|'),
ncarBrands = ['HONDA', 'SUZUKI', 'DAIHATSU', 'WULING', 'TOYOTA']
for (let brand of brands) {
if (this.get('cart.contents.condition') === 'ncar' && ncarBrands.includes(brand)) {
obj_brands_new.push({ 'index': brand, 'value': brand, 'id': brand.dasherize() });
} else {
obj_brands_all.push({ 'index': brand, 'value': brand, 'id': brand.dasherize() });
}
}
return {
brands: (this.get('cart.contents.condition') === 'ncar')obj_brands_new.sortBy('value') : obj_brands_all.sortBy('value')
}
})
this code template.hbs:
<ProductFilterNew @filters= @origin="new" @targetUrl="new" @carmodels= @isNcar=true @isNewPage=true />
I expect the output list brand ['HONDA', 'SUZUKI', 'DAIHATSU', 'WULING', 'TOYOTA']
Aucun commentaire:
Enregistrer un commentaire