ion.rangeSlider
ion.rangeSlider copied to clipboard
prettify function arg returns 0?
I'm doing the following...
var ids = [ 1, 5, 20, 100, 1000 ];
var names = [ 'one', 'five', 'twenty', 'one hundred', 'one thousand' ];
console.log(ids);
console.log(names);
$('input').ionRangeSlider({
values: ids,
prettify function (n) {
console.log(n);
return n;
});
On page load (startup) I see a list of my ids as you would expect. n
looks like it's being populated with the id. Whats weird is that i see two console.log entries showing n
as being 0.
The slider loads and i see the first option as being 1. If i click the slider but not moving it i see a console log entry of 0? Also, not sure why the prettify function fired when I didn't move anything.
So now i start dragging the slider forward and n
no longer looks to be set to the selected value from ids but now looks to be the numbered position of the slider. (1, 2, 3, 4, etc). So it appears that prettify is setting n to two different values.
If i drag the slider all the way to the end and then back to the beginning I can see that n
is being incremented and decremented by 1 and when i get back to the first position n
is now 0
Now that I've clicked on the slider I can now move it by the keyboard. If i'm on the first value and hit the left arrow key a couple times I see n
as being 0 each time i hit the left key, but when i try and hit the right arrow n
is 0 again, and again, and again, and finally increments to 1.
There seams to be some inconsistencies here.
Here's a working example of the issue. https://jsfiddle.net/j97s8dax/1/
Open your browsers console and watch the log when you click run. You will see 1, 10, 100, 1000, 0, 0 displayed. So if prettify was passing the value selected that would make sense... other than those weird random 0's. Now slide the slider once to the right and you will see 1 was printed to the console log, it should of been 10 if we were going by the value selected. Now slide it one more to the right, we are now on the 100 value but the console log showed 2... Ok so now it looks like we're getting our slider position? The data being feed to prettify looks to be inconsistent to me.
Hi, here is the workaround: https://jsfiddle.net/IonDen/98m41jzv/
Is this an issue that's going to be fixed? The workaround you provided works for my original example but does not for the following...
https://jsfiddle.net/4o0ymusL/