Issue with the checkbox that duplicate the check with bootstrap for Ember.js -
when click on checkbox, monday example, checbox validated, other monday, each element validated.
i'll show template, can more clear you.
when click on monday, check validated both, , value inside js validated both.
here handlebars.js templates define page. file shedule-timeframe.hbs.
{{#if timeframe}} {{log "monday " timeframe.enabledonmonday}} {{log "start " timeframe.starttime}} <div class="col-lg-12"> <!--be careful, it's monday, friday, tuesday, saturday, wednesday, sunday, thursday --> <div class="col-lg-3"> {{form.element controltype='checkbox' label=(t 'schedule.monday') property="enabledonmonday" value=timeframe.enabledonmonday}} {{form.element controltype='checkbox' label=(t 'schedule.friday') property="enabledonfriday" value=timeframe.enabledonfriday}} </div> <div class="col-lg-3"> {{form.element controltype='checkbox' label=(t 'schedule.tuesday') property="enabledontuesday" value=timeframe.enabledontuesday}} {{form.element controltype='checkbox' label=(t 'schedule.saturday') property="enabledonsaturday" value=timeframe.enabledonsaturday}} </div> <div class="col-lg-3"> {{form.element controltype='checkbox' label=(t 'schedule.wednesday') property="enabledonwednesday" value=timeframe.enabledonwednesday}} {{form.element controltype='checkbox' label=(t 'schedule.sunday') property="enabledonsunday" value=timeframe.enabledonsunday}} </div> <div class="col-lg-3"> {{form.element controltype='checkbox' label=(t 'schedule.thursday') property="enabledonthursday" value=timeframe.enabledonthursday}} </div> </div> <br> <br> <br> <br> <br> <div class="col-lg-4"> {{#form.element label=(t 'schedule.start_time')}} {{input type='text' placeholder='13:37'value=(mut timeframe.starttime) class='form-control'}} {{/form.element}} </div> <div class="col-lg-4"> {{#form.element label=(t 'schedule.end_time')}} {{input type='text' placeholder='18:42'value=(mut timeframe.endtime) class='form-control'}} {{/form.element}} </div> {{/if}}
and here, call templates. file shedule-form.js. can see call file schedule-timeframe.hbs @ line 20.
{{#bs-form formlayout="horizontal" model=schedule |form|}} <legend>{{t 'timeframes'}}</legend> <div class="col-md-12"> <div class="row"> <div class="pull-left col-md-1"> {{bs-button defaulttext=(t 'add') type='success' onclick=(action 'addtimeframe')}} </div> <div class="col-md-1"> {{bs-button defaulttext=(t 'submit') type="primary" onclick=action buttontype="submit"}} </div> </div> <br> <br> <div class="row"> {{#each schedule.timeframes |tf|}} {{log "tf " tf}} <div class="panel panel-default"> <br> <div class="row"> {{schedule-timeframe form=form timeframe=tf model=tf}} </div> <div class="col-md-2"> {{bs-button defaulttext=(t 'remove_selected') type='danger' onclick=(action 'removetimeframe')}} </div> <br> <br> </div> {{/each}} </div> </div> {{/bs-form}}
tldr: have issue checbox duplicate when click on 1 of them, same value, on different [timeframe].
so solve creating own onchange!
{{form.element controltype='checkbox' label=(t 'schedule.monday') value=(mut timeframe.enabledonmonday) onchange=(action (mut timeframe.enabledonmonday))}}
with onchange, can set value of each timeframe.
Comments
Post a Comment