当我将股票值(value)设置为 100 时,它起作用了。
此问题的实时副本在这里:http://mypcdeals.com/product-list.php?c=motherboards#limit=20&p=0
产品搜索左下角的“SATA 3GB/S PORTS” slider 未正确格式化,最小值为 0,最大值为 10。
这里是设置它的代码:
initPopulateRangeSliders: function () {
$('.rangefilter').each(function () {
var id = $(this).attr('id');
//get the max value for this field
$.getJSON("/getSliderMax?f=" + id, function (data) {
if (data.success)
{
var theMax = data.max;
alert('Max should be set to:' + theMax);
var theSlider = document.getElementById(id);
var settings = {
start: 0,
behaviour: 'snap',
range: {
'min': 0,
'max': theMax
}
}
noUiSlider.create(theSlider, settings);
}
});
});
如果您加载页面,您将看到警告框显示最大值,但我收到以下错误:
Uncaught Error :noUiSlider:“范围”包含无效值。
为什么?
最佳答案
initPopulateRangeSliders: function () {
$('.rangefilter').each(function () {
var id = $(this).attr('id');
//get the max value for this field
$.getJSON("/getSliderMax?f=" + id, function (data) {
if (data.success)
{
var theMax = data.max;
alert('Max should be set to:' + theMax);
var theSlider = document.getElementById(id);
var settings = {
start: 0,
behaviour: 'snap',
range: {
'min': 0,
'max': parseInt(theMax)
}
}
noUiSlider.create(theSlider, settings);
}
});
});
关于javascript - jQuery NoUiSlider 不能使用最大值 10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31801401/