我尝试并行使用几个bootstrap touchspin小部件。它们的最小和最大微调值取决于相邻微调器的值。在这里,我遇到了错误消息(TypeError: value.toFixed is not a function
)和带有微调器值的意外行为。我做错了吗?
$(document).ready(function() {
var mini1 = 1.0;
var maxi1 = 2.0;
$('#minim').TouchSpin({
//min: mini1.toFixed(3), //this produces error
min: mini1, //this avoids the error
max: maxi1,
step: 0.001,
initval: 1.5,
decimals: 3,
//boostat: 5,
//maxboostedstep: 1,
postfix: 'eV',
//mousewheel: true
})
.on('touchspin.on.stopspin', function(e) {
//var temppi1 = $(this).val(); //gives correct spinner value when min or max are reached during spinning
var temppi1 = String($(this).val()); //produces erroneous value when min or max are reached during spinning
$('#labeli1').text("Spinner value: " + temppi1);
})
.end();
});
.huihai {
padding-left: 50px;
width: 240px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-touchspin/3.0.3/jquery.bootstrap-touchspin.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-touchspin/3.0.3/jquery.bootstrap-touchspin.min.js"></script>
<div class='huihai'>
<label id='labeli1' class="control-label">Min.Spinner:</label>
<input class="form-control input-sm" id="minim" name="minim" />
</div>