Opened 9 years ago

Closed 9 years ago

Last modified 6 years ago

#5782 closed bug (worksforme)

Clicking on slider with negative values causes error 'closestHandle is undefined'

Reported by: Thangalin Owned by:
Priority: major Milestone:
Component: ui.slider Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:

Description

If you *RECREATE* a slider with min: -2, max: 0, value: 0 then click on the slider, the following error occurs:

closestHandle is undefined

The line in question:

closestHandle

.addClass( "ui-state-active" ) .focus();

Change History (7)

comment:1 Changed 9 years ago by Thangalin

Inserting a line after the workaround for but 3736:

alert( "index: " + index +

" @0:" + this.values(0) + " @1:" + this.values(1) );

Reveals:

index: undefined @0:-65 @1:50

comment:2 Changed 9 years ago by Thangalin

It appears the function normValueFromMouse is returning a value of -65115 when it should return 50 (when clicking on the right-most slider whose value is 50 and left-most slider whose value is -65).

comment:3 in reply to:  1 Changed 9 years ago by Thangalin

Line 432: valueMouse = this._valueMin() + percentMouse * valueTotal;

valueMouse should be 48, but it is -65115.

comment:4 Changed 9 years ago by Thangalin

I changed the following lines to use parseInt:

_valueMin: function() {

return parseInt( this.options.min );

},

_valueMax: function() {

return parseInt( this.options.max );

},

I think negative values were treated as strings, when added as follows:

$.each( data, function( index, value ) {

options.push(

'<option value="' + value + '">' + value + '</option>' );

comment:5 Changed 9 years ago by Thangalin

Also, the source code comment in the documentation for the UI Slider should begin with "/*!" not "/*" (i.e., append a bang) to preserve the copyright information in the minified version. *OR* remove the bang from everywhere else. Either way, it should be consistent. And this should be in a different bug. ;-)

comment:6 Changed 9 years ago by Scott González

Resolution: worksforme
Status: newclosed

I'm not seeing any problems: http://jsbin.com/epowu3

comment:7 Changed 6 years ago by Scott González

Milestone: TBD

Milestone TBD deleted

Note: See TracTickets for help on using tickets.