我有一个简单的自举timepicker。与timepicker我连接三个单选按钮:Bootstrap timepicker - 点击更改minutestep
<div class="checkbox">
<label><input id="customTimeslot" type="radio" name="autoTimeslot" value="custom" checked="checked"> Use custom</label><br>
<label><input id="autoHalfHourTimeslot" type="radio" name="autoTimeslot" value="half_hour"> Generate half hour slot</label><br>
<label><input id="autoTimeslot" type="radio" name="autoTimeslot" valu> Generate one hour slot</label>
</div>
在我的自定义JavaScript文件,我有这样的设置:
$('.timepicker').timepicker({
'showMeridian': false,
'showInputs': false,
'minuteStep': 15
});
而且我不会是,如果半小时单选按钮被选中,minuteStep应设置为30。
所以,我虽然这将工作:
$("#autoHalfHourTimeslot").change(function(){
if(this.checked) {
$('.timepicker').timepicker({
'showMeridian': false,
'showInputs': false,
'minuteStep': 30
});
}
});
如何有史以来,只有当我删除最初的代码时,minuteSteps总是增加15,然后它将应用那30分钟的步骤。但是如果没有点击单选按钮,我需要15分钟的步骤。感谢您的帮助。
不,我进入的是$(“#autoHalfHourTimeslot”)变化(函数(){。所以这不是问题,出于某种原因,它不会将新设置添加到时间选择器 – Milo