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.7k stars 657 forks source link

using variables for the start event #1208

Closed jase20 closed 2 years ago

jase20 commented 2 years ago

Very much liking all the functionality and flexibility of noUiSlider! My project is Arduino based that uses a web app for the controls. The primary form in the web app uses a 3 handle slider for 3 ambiance levels, cool, warm and hot. I use variables for the Start Event and retrieve the data via input fields.

So in Arduino IDE it looks like this...

var stepsSlider = document.getElementById('steps-slider'); var cool = document.getElementById('cool'); var warm = document.getElementById('warm'); var hot = document.getElementById('hot'); var inputs = [cool, warm, hot];

var c=" + cool + ";var w=" + warm + ";var h=" + hot + ";

noUiSlider.create(stepsSlider, { start: [c, w, h], connect: [true, true, true, true], tooltips: true, format: wNumb({ decimals: 0 }), range: { min: 0, max: 40 } });

Now, this all works fine the first time round, even 2 or 3 times if I only change one value. But usually when the form is submitted, the script fails to load and so the slider fails to show. I have to refresh the page or reopen a new page for it to load it all up, even though I'm preloading the page. Any ideas on how to resolve this? Any help very much appriciated.

Jase

leongersen commented 2 years ago

Hi Jase, Glad you are liking noUiSlider!

var cool = document.getElementById('cool'); gets you the element with id cool. var c=" + cool + "; puts a string with the literal value + cool + in c. You are probably looking to get the input value from the cool input, using var c = cool.value. (same for the other inputs)

jase20 commented 2 years ago

You absolute star Léon! I was just about to go in another direction when you kindly AND swiftly came to my rescue! Thank you so much :)))

leongersen commented 2 years ago

Glad I could help!

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.