Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Propose for #3029 empty value not refreshing slider #3033

Closed
wants to merge 1 commit into from

3 participants

Maurice Gottlieb Eddie Monge John Bender
Maurice Gottlieb

Fix for #3029: checking for empty slider-value

Maurice Gottlieb

because parseFloat( null ) returns NaN

Eddie Monge

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

Maurice Gottlieb

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

Eddie Monge

Oops, yeah you are right. seems good then

Maurice Gottlieb

@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?

John Bender

@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

John Bender 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. Maurice Gottlieb
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
3  js/jquery.mobile.forms.slider.js
View
@@ -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.