Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Propose for #3029 empty value not refreshing slider #3033

Closed
wants to merge 1 commit into from

3 participants

@MauriceG

Fix for #3029: checking for empty slider-value

@MauriceG

because parseFloat( null ) returns NaN

@eddiemonge

that could leave percentage as a negative number then. That might still be an issue anyway though.

@MauriceG

@eddiemonge Are you sure? A negative percentage value will be set to 0 a few lines later.

@eddiemonge

Oops, yeah you are right. seems good then

@MauriceG

@eddiemonge Danke schön means: thanks a lot.
I've tested it with various values for min/max. No issues.
btw: since when there is a step attribute for range sliders? Did I miss something?

@johnbender

@MauriceG

From the example in the bug, $("#myslider").val('').slider('refresh'); , it appears that your check is sort of disjoint from the check against null above. That is, if the null check above went away, the check would only be looking to see if the val param was undefined. I've committed the following change from

if ( val == null ) {
    val = cType === "input" ? parseFloat( control.val() ) : control[0].selectedIndex;
}

to

if ( val == null ) {
    // note the addition of || 0
    val = cType === "input" ? parseFloat( control.val() || 0 ) : control[0].selectedIndex;
}

with tests here

@johnbender johnbender closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 12, 2011
  1. @MauriceG
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 0 deletions.
  1. +3 −0  js/jquery.mobile.forms.slider.js
View
3  js/jquery.mobile.forms.slider.js
@@ -270,6 +270,9 @@ $.widget( "mobile.slider", $.mobile.widget, {
if ( val == null ) {
val = cType === "input" ? parseFloat( control.val() ) : control[0].selectedIndex;
}
+ if ( isNaN( val ) ) {
+ val = 0;
+ }
percent = ( parseFloat( val ) - min ) / ( max - min ) * 100;
}
Something went wrong with that request. Please try again.