PDA

View Full Version : Slider not returning its current value



glafrance
24 Jul 2013, 10:41 AM
The following code works as expected. If the slider is moved to the middle, getValue() correctly returns 50.<br><br>But in my larger application, which is ExtJS 4.1.2, I set the initial slider value to 50 from a model (the value of 50 comes from a backend REST call). And when user changes the slider value and clicks Save, the value returned by getValue() is always 0.<br><br>So why is the slider not returning the correct value? It does not even return the value that is currently in the model.


Ext.onReady( function (){
var window = new Ext.Window({
width: 540,
height: 400,
autoScroll: true,

items: [{
xtype: 'slider',
id: 'sliderComp',
width: 400,
increment: 50,
minValue: 0,
maxValue: 100
}, {
xtype: 'button',
text: 'Show Value',
listeners: {
'click': function () {
var slider = Ext.getCmp('sliderComp');
if (slider.getValue() == 0) {
alert("value is 0");
} else if (slider.getValue() == 50) {
alert("value is 50");
} else if (slider.getValue() == 100) {
alert("value is 100");
}
}
}
}]
}).show();
});

glafrance
24 Jul 2013, 11:16 AM
Never mind, I was calling getValue without the parenthesis, which of course won't work.