Search and Top Navigation
#7989 closed bug (notabug)
Opened January 05, 2012 09:36PM UTC
Closed January 05, 2012 09:49PM UTC
Last modified January 07, 2012 12:18PM UTC
Error in Slider
Reported by: | darshana | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.9.0 |
Component: | ui.slider | Version: | 1.8.16 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
$( "#temperature" ).slider({
range:"min",min: 0,value:1,max: 1,step: 0.01,animate: true,orientation: "vertical",
change: function( event, ui ) {alert($( "#temperature" ).slider("value" ));},slide: function( event, ui ) {$( "#temp_val" ).val($( "#temperature" ).slider("value" ));}}); });
As I slide the slider, the value gets displayed in a textbox. However, the 2 values (one being showed in the alert box and the ones being displayed in textbox) are not the same... difference between them is random as well, sometimes .01 and sometimes .02.
Thanks a lot..
Biggest issue is that I have set the maximum as max=1 but when I pull the slider to its highest position, the slide event gives 0.99 while the onchange event gives 1. the Slide event is not working properly because if max=1, the slider gives these values [0.99,1,0.99,0.98,0.97,...] I need to play around to get the 1.. Can someone please help me out if I am getting something wrong?
Attachments (0)
Change History (4)
Changed January 05, 2012 09:49PM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |
Changed January 06, 2012 06:51AM UTC by comment:2
Hi
could you please explain it to me again? I cnt get it.. sorry..
I am using the slider for a simulation model, so its like when the handle is being used, the slide event helps to indicate which is the current slider value.
I used the change event so as to trigger a serverside call, which takes the slider value being displayed in the textbox as parameter.
Can you guide me as to whether the choice of event trigger is appropriate or not?
Thanks a lot Scott :)
Changed January 06, 2012 01:23PM UTC by comment:3
From the documentation for the slide event: "This event is triggered on every mouse move during slide. Use ui.value (single-handled sliders) to obtain the value of the current handle."
You want to know the value that the slider is moving to, not the value that the slider currently has. You need to use ui.value
from the event to get that.
$( "#temperature" ).slider({ slide: function( event, ui ) { $( "#temp_val" ).val( ui.value ); } });
Changed January 07, 2012 12:18PM UTC by comment:4
Thanks a lot.. I got it straight now :)
The value is not updated until after the slide event. That's why the highest value you're seeing is 0.99. When you do see it alert 1, it's because you've already reached the max and have moved one step lower.