最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - noUiSlider "Must pass a formatter for all handles" with tooltip formatting - Stack Overflow

programmeradmin0浏览0评论

When i try and format the decimal places of the tooltip i get the following error. Unsure why as im copy pasting the tooltip line from the documentation.

"Uncaught Error: noUiSlider: must pass a formatter for all handles."

jQuery(document).ready(function(){
var frequencySlider = document.getElementById('frequencySlider');

noUiSlider.create(frequencySlider, {
    start: [ 4 ],
    step: 1,
    range: {
        'min': [  1 ],
        'max': [ 40 ]
    },
        tooltips: [true, wNumb({ decimals: 1 })],
    pips: {
        mode: 'values',
        values: [1, 10, 20, 30, 40],
        density: 100,
        stepped: true,
    }

});



var frequencyNumber = document.getElementById('rangePickerTextMonthly');

frequencySlider.noUiSlider.on('update', function( values, handle ) {

    var value = values[handle];
        frequencyNumber.value = value;
            optionChange();
});



frequencyNumber.addEventListener('change', function(){
    frequencySlider.noUiSlider.set([null, this.value]);
});

});

When i try and format the decimal places of the tooltip i get the following error. Unsure why as im copy pasting the tooltip line from the documentation.

"Uncaught Error: noUiSlider: must pass a formatter for all handles."

jQuery(document).ready(function(){
var frequencySlider = document.getElementById('frequencySlider');

noUiSlider.create(frequencySlider, {
    start: [ 4 ],
    step: 1,
    range: {
        'min': [  1 ],
        'max': [ 40 ]
    },
        tooltips: [true, wNumb({ decimals: 1 })],
    pips: {
        mode: 'values',
        values: [1, 10, 20, 30, 40],
        density: 100,
        stepped: true,
    }

});



var frequencyNumber = document.getElementById('rangePickerTextMonthly');

frequencySlider.noUiSlider.on('update', function( values, handle ) {

    var value = values[handle];
        frequencyNumber.value = value;
            optionChange();
});



frequencyNumber.addEventListener('change', function(){
    frequencySlider.noUiSlider.set([null, this.value]);
});

});
Share Improve this question asked Oct 17, 2017 at 16:37 loveforfire33loveforfire33 1,1184 gold badges26 silver badges48 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

The start option sets the number of handles and corresponding start positions. In your example, you have two tooltips formatter

    tooltips: [true, wNumb({ decimals: 1 })]

Instead you need one for your only handle

    tooltips: [true] 

Or

    tooltips: [ wNumb({ decimals: 1 })]

If you want to show tooltips for all Handles just use tooltips : true and if not use tooltips : false

发布评论

评论列表(0)

  1. 暂无评论