0

I am using the jquery-ui slider with 2 handles. But when I move the right handle on top of the left handle and after that, grab the top handle, the bottom one is selected.

This error also occur when I move one handle in the vertical axis.

 $('#slider').slider({
  min: 0.0,
  max: 10,
  step: 0.1,
  values: [5, 5],
});

css

#slider .ui-state-default:nth-of-type(1) {
  border: solid 2px red;
  top:25px;
}

#slider .ui-state-default:nth-of-type(2) {
  border: solid 2px blue;
}

See this fiddle

Why is jquery-ui returning the wrong index? How can I fix this problem?

q-jack
  • 366
  • 2
  • 3
  • 17
  • Are you trying to setup a `range` slider? By default, it only sets 1 handle unless `reange: true` option is set. – Twisty Mar 13 '17 at 22:19
  • Appears to work exactly as expected: https://jsfiddle.net/Twisty/j279gu8e/ – Twisty Mar 13 '17 at 22:28
  • Can also style it better: https://jsfiddle.net/Twisty/j279gu8e/1/ – Twisty Mar 13 '17 at 22:33
  • No I do not want to setup a range slider. How can you say @Twisty that it works exactly like expected. When I want to move the bottom blue handle in your fiddle the red one is moving. I was not expecting that. Is that only in chrome? – q-jack Mar 16 '17 at 07:21
  • Since both handles have the same position, slider lays them on top of each other. I witnessed the same activity in FireFox. You can test this by setting the default value to something like `[4, 6]` for example. – Twisty Mar 16 '17 at 14:43
  • Yes, that was also my observation.I found this bug in the jquery-ui bug tracker https://bugs.jqueryui.com/ticket/9553 , but this is 4 years ago and nothing happens. Is there a workaround for this? – q-jack Mar 17 '17 at 07:22
  • There is a proposed fix. Would have to examine the 1.12.1 code to see if it was accepted. Otherwise apply the fix in your own code. – Twisty Mar 17 '17 at 14:37
  • I'm not happy with manipulating the jquery-ui code, because of further updates. I think I am going to use different slider not the jquery ones. But thanks for the replies – q-jack Mar 20 '17 at 11:38

0 Answers0