Question

I'm using the noUiSlider, it works but the on slide event is called only once and not multiple times.

My code:

$("#prix-slider").noUiSlider({
    start: [250,300],
    connect: true,
    margin: 4,
    range: {
        'min': 250,
        'max': 300
    },
    serialization: {
        format: {
            decimals: 0
        }
    }
});
var prixSlider = "#prix-slider";
function updateSliderValues(slider) {
    console.log(slider);
    var sliderValues = $(slider).val();
    console.log(sliderValues[0]);
    console.log(sliderValues[1]);
}
$(prixSlider).on('slide', updateSliderValues(prixSlider) );

What am I missing?

Was it helpful?

Solution

You must use function(){} to use updateSliderValues

$(prixSlider).on('slide', function(){
    updateSliderValues(prixSlider) 
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top