You can might be getting “TypeEror: closestHandle is undefined” or “TypeError: s is undefined” if you are using a slider with negative numbers.

I’m able to reproduce is here:

broken: http://jsbin.com/epowu3/3/edit

but the solution is easy.  Min and max are numbers, not strings, and “-100″+10 == “-10010”

so change “100” to 100 and “-100” to -100, and all works well as seen here:

works: http://jsbin.com/epowu3/4/edit

have fun.

Cameron

 

2 Comments

  1. Mel says:

    Thanks for this, it led me to a solution of a similar problem. Most variables when using jquery are strings because they originate from the DOM. I use the following in a slider definition to force numeric values in min and max:

    $(‘#mdRange’).slider({
    range: true,
    min: 1 * $(‘#mdLower’).text(), // force conversion to number
    max: 1 * $(‘#mdUpper’).text(),
    values: [1900, 1918],
    slide: slideYr,
    step: 1
    });

  2. Napoleon says:

    Great Post, I was scratching my head for quite sometime, in yii framework CJUISliderinput had the same issue, then i changed it int and everythign started working like a charm.

Leave a Reply