Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery UI Slider with Multiple handles: How to stop the handles from crossing?

I'm developing a quick solution that uses a Slider with multiple handles to define widths for a dynamic layout.

I've attempted to use both ExtJS3 and the latest JQuery UI.

In ExtJS, you can constrain the handles so the don't cross over each other, and it's quite an intuitive approach to the UI I need, however there are reasons why I would rather not use ExtJS for one 'island' in a sea of JQuery.

So, does anyone know of a secret attribute, or a bit of code that constrains multiple handles in the JQuery slider ?

For clarity: if you have a slider with 2 handles, one at 40 and one at 60; the constraint would stop you dragging the handle at 60 down to 20, without first moving the 40 one.

like image 209
Russ Clarke Avatar asked Dec 28 '22 08:12

Russ Clarke


1 Answers

In the slide event you can constrain the handle movement by checking the slider values and returning true to allow the slide or false to prevent it (see the jQuery UI docs for more information)

like image 117
Phil Hale Avatar answered Jan 19 '23 13:01

Phil Hale