javascript - jQuery NoUiSlider 不能使用最大值 10

标签 javascript jquery nouislider

当我将股票值(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/

相关文章:

javascript - 通过javascript按按钮加载嵌入式MP4视频

javascript - 将scrollTop值从textarea复制到div

javascript - FF5+ 中的 window.opener.focus() 问题

javascript - NoUISlider 不工作

javascript - noUiSlider 长数舍入错误

css - 使用文本和形状自定义 noUiSlider handle 成圆形

javascript - 如何实时更新网页?

javascript - Kendo optionLabel 下拉菜单无法正常工作

javascript - 点击后如何取消触发

jquery - 如何将一个元素附加到另一个元素?