2016-08-05 40 views
0
翡翠数据的多个选项

“数据”代表当前选择的宠物 “宠物”代表MongoDB中 所有的宠物试图选择先前已选定为冲突的宠物试图自动选择蒙戈

label.col-sm-3.control-label(for='petConflicts') Pet Conflicts 
.col-sm-7 
select.form-control(name='petConflicts', multiple=true) 
    each pet, index in pets 
    option(value=pet._id, selected=data.petConflicts[index]===pet._id) #{pet.name} 

是有点打算关闭

label.radio.col-sm-3 
     input(type='radio', name='gender', checked=data.gender=='male', value='male', data-toggle='radio') 
     span Male 
    label.radio.col-sm-3 
     input(type='radio', name='gender', checked=data.gender=='female', value='female', data-toggle='radio') 
     span Female 

女巫的伟大工程,我失去的东西是可以自动选择多个选项?

回答

0
  if data.petConflicts.indexOf(pet._id) > -1 
      option(value=pet._id, selected=true) #{pet.name} 
      else 
      option(value=pet._id, selected=false) #{pet.name} 

 select.form-control(name='plan') 
     option(value=1, selected=data.plan===1) Once a week 
     option(value=2, selected=data.plan===2) Twice a week 
     option(value=3, selected=data.plan===3) Three times a week 
     option(value=4, selected=data.plan===4) Four times a week 
     option(value=5, selected=data.plan===5) Five times a week 
     option(value=6, selected=data.plan===6) Six times a week 
     option(value=7, selected=data.plan===7) Every day 

都结束了,我的工作。