Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No UiSlider remove decimal?

Tags:

nouislider

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'));
like image 675
Maxim Avatar asked Dec 15 '22 19:12

Maxim


2 Answers

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)
    }
});
like image 194
Zze Avatar answered Mar 20 '23 05:03

Zze


Decimals decimals: false is invalid, use decimals: 0. Also, you are setting formatting for the .val() method. Use it like this:

$('#slider_01').Link('lower').to($('#value-lower_1'), null, wNumb({
    decimals: 0,
    thousand: ',',
    prefix: '$ ',
}));
like image 35
Lg102 Avatar answered Mar 20 '23 06:03

Lg102