leongersen / noUiSlider

noUiSlider is a lightweight, ARIA-accessible JavaScript range slider with multi-touch and keyboard support. It is fully GPU animated: no reflows, so it is fast; even on older devices. It also fits wonderfully in responsive designs and has no dependencies.
https://refreshless.com/nouislider/
MIT License
5.67k stars 660 forks source link

No changes detected after changing the slider #1183

Closed ReindDooyeweerd closed 2 years ago

ReindDooyeweerd commented 2 years ago

Not sure what i'm doing wrong but i'm struggling with change detection. I have a filterbar with some checkboxes and some sliders in it.

Detecting changes inside that sidebar with a simple document.getElementById("sidebar").addEventListener("change", function() {...});. It triggers when changes on checkboxes and input fields are detected however after changing an input value with noUiSlider it doesn't trigger.

I made a simple example over here:

https://codepen.io/reind/pen/OJOLxqL

Sliding the sliders doesn't trigger the console.log but changing the value in the input field itself does. Anyone who could tell me what i'm missing?

leongersen commented 2 years ago

Setting value on input does not produce a change event. You can either fire one yourself, or, simpler, call your event handler:

function changeHandler () {
  console.log("change detected");
}

sliderBar.noUiSlider.on("change", function (values, handle) {
    /* ... */

    changeHandler();
});

document.getElementById("container").addEventListener("change", changeHandler);
github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.