PDA

View Full Version : Slider.setValue not initializing in the correct position?



billyto
18 Jul 2011, 8:00 AM
I'm trying to initialize a slider at 50, in a 0 to 100 range,

if I set the config value to 50, the value is preserved but the thumb keeps in 0, and if I try to changed by:

slider.setValue(50);

I'm getting:
TypeError: Result of expression 'thumb.dragObj' [undefined] is not an object.


Funny that the slider moves without problems if I change the value using firebug console.


slider = new Ext.form.Slider({
cls:'slider',

value: 50,
minValue: 0,
maxValue: 100,
width:325,
height:65,
maxWidth:200,
ui:'dark',
listeners:{
change :{
fn: function(container,thumb, new_val, old_val){
//todo
}
}
}

});

art.dev.ext
18 Jul 2011, 8:32 AM
What type of container does your slider have ?

I got stuck with this kind of error when I tried to have a slider inside a Toolbar,
Forcing an Ext.Panel as a Container of the slider did the trick

You may check :
http://www.sencha.com/forum/showthread.php?128905-slider-thumb-initvalue-broken&highlight=thumb
or
http://www.sencha.com/forum/showthread.php?134496-Slider-%28stand-alone%29-thumb-position-wrong-up-when-placed-in-Ext.Container&highlight=slider

billyto
18 Jul 2011, 9:13 AM
Thanks!!!
I was really lost debugging this one, I fixed using your recommendation on the other post:

"""sliderElementReference.getThumb().dragObj.updateBoundary();"""


How did you find out it was a boundaries issue?

art.home.ext
18 Jul 2011, 10:56 AM
Searching the forum for "dragObj" :D
(This was not a post of mine)