Closed gmajoulet closed 10 years ago
Hi André,
great library, thanks again! I do have exactly the same issue. My favorite behavior would be: if max = 0 => disable slider.
cheers,
Eugene
I'll look into it. Cheers guys!
Would be great if you guys could give me a feedback if the issue is fixed with pr #59.
It's already in the develop
branch and planed to be in the next release.
No it's not. You're still not checking if the value is false OR 0 (which is false too). So if it's 0, it goes to the fallback 100.
e.g. this.$element[0].getAttribute('max')
etc. is not a number. So if the attribute is set, it will always use the value if not it is null
and will use the fallback.
No... http://jsfiddle.net/3ussf/
Like I said, 0 is falsy in JavaScript.
Anyway, I need to set max to 0, so I'll keep using my patched version.
You are totally right the number 0
is falsy in JS.
The point is that element.getAttribute('attr')
will return a string and a string isn't false right!?
After I got the right value from the attr (min, max, whatever...) it will be converted into a floating point number to be able to calculate with it.
e.g.
this.max = parseFloat(this.$element[0].getAttribute('max') || 100)
this.$element[0].getAttribute('max')
if there is a attribute max
it is a string and never false.
this.$element[0].getAttribute('max')
will be null
if there is no attribute max
in this case
this.max
will be 100 instead.
It's impossible to set a max to 0 for now
0 is false, so it goes to 100 by default.