No UiSlider remove decimal?

Maxim picture Maxim · Sep 15, 2014 · Viewed 9.2k times · Source

How to remove decimals digit from linked output

I am using this code

$("#slider_01").noUiSlider({
    start: [2000, 24000],
    connect: true,
    step: 0.01,

    range: {
        'min': 0,
        'max': 28500
    },
    format: wNumb({
        decimals: false,
        thousand: ',',
        prefix: '$ ',
    })
});

$('#slider_01').Link('lower').to($('#value-lower_1'));

$('#slider_01').Link('upper').to($('#value-upper_1'));

Answer

Zze picture Zze · Oct 27, 2020

I didn't have access to the wNumb library in the environment I was working with.

Had a look under the hood in the library and this also works:

$("#slider_01").noUiSlider({
    ...
    format: {
        to: (v) => parseFloat(v).toFixed(0),
        from: (v) => parseFloat(v).toFixed(0)
    }
});