Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#9424 closed bug (notabug)

$('.ui-slider-handle:first').offset() incorrect if hidden

Reported by: warmski Owned by: warmski
Priority: minor Milestone: none
Component: ui.slider Version: 1.10.3
Keywords: Cc:
Blocked by: Blocking:

Description

Similar to ticket 2428. If the slider is in a hidden div when created it creates the handles in the right place but does not set the correct offset values. The code I am using is: $('#slider').slider({

min:0, max:1000000, step:5000, values: [100000, 500000],...

var handle1x = $('.ui-slider-handle:first').offset().left; When visible on create handle1x is 115 When hidden on create handle1x is -1. Thanks

Change History (4)

comment:1 Changed 6 years ago by tj.vantoll

Owner: set to warmski
Status: newpending

Are you trying to get the offset while the slider is still hidden? jQuery has never supported this.

If not could you please create a test case that shows this. You can use this as a starting point: http://jsfiddle.net/tj_vantoll/Hd4Ca/.

Thanks.

comment:2 Changed 6 years ago by warmski

Status: pendingnew

Ahh okay. I am trying to set a highlighter between two handles (as in the link http://jsfiddle.net/warmski/Hd4Ca/14/). The whole section is collapsed (hidden) until the user clicks expand. In the example the highlighting works great once the change / slide event is triggered. It also works great if the slider isn't hidden on create.

Any suggestions for a workaround, other than to quickly display the slider, set it up then hide it?

Thanks

comment:3 in reply to:  2 Changed 6 years ago by tj.vantoll

Resolution: notabug
Status: newclosed

Replying to warmski:

Ahh okay. I am trying to set a highlighter between two handles (as in the link http://jsfiddle.net/warmski/Hd4Ca/14/). The whole section is collapsed (hidden) until the user clicks expand. In the example the highlighting works great once the change / slide event is triggered. It also works great if the slider isn't hidden on create.

Any suggestions for a workaround, other than to quickly display the slider, set it up then hide it?

Thanks

It looks like you're trying to recreate the built in functionality a range slider provides: http://jsfiddle.net/tj_vantoll/r87b8/.

comment:4 Changed 6 years ago by warmski

D'oh! I had three handles originally and so couldn't use range but now I have two I can. Oh well a fun afternoon getting used to jQuery UI. Thanks for such a speedy response and your help.

Note: See TracTickets for help on using tickets.