I was working on a situation where I had two jQuery sliders that I took from here: http://jqueryui.com/demos/slider/#rangemin
I needed to limit it to the basis of the meaning of another, so that they would not overlap. I came up with the code below. This worked, except for one very unpleasant problem - when I was dragging the sliders, they passed each other while I was still dragging them, only to restore the limited value when I release the mouse button.
Purely by accident, I found a solution to adding ui.someunknownmethod ('1'); below.
So my question is: can I save this line without any problems?
<style type="text/css"> body{ font: 62.5% "Trebuchet MS", sans-serif; margin: 50px;} #slider1 .ui-slider-range { background: #8ae234; } #slider2 .ui-slider-range { background: #729fcf; } #sliderContainer{ width: 400px; margin: 6px 0px; } </style> </head> <body> <div id="sliderContainer"> <div id="slider1"></div> </div> <div id="sliderContainer"> <div id="slider2"></div> </div> <span id="txt">-</span> <span id="txt2">-</span> <script> $(function(){ $("#slider1").slider({ orientation: "horizontal", range: "max", max: 255, value: 50, slide: refresh1, change: refresh1 }); $("#slider2").slider({ orientation: "horizontal", range: "max", max: 255, value: 30, slide: refresh2, change: refresh2 }); }); function refresh1(e, ui) { var slider2 = $("#slider2"); var v1 = ui.value; var v2 = slider2.slider('value'); if(v1 < v2) { $("#slider1").slider('value', v2); </script> </body>
EDIT: Do not use the unhandled exception throwing approach - it will work in most browsers, of course, except for the older IE, where the browser displays a pop-up window for the message every error occurs. This would be very unpleasant for the user!
So far, I have not been able to find what I was looking for (well, except for rewriting the slider user interface code), so if anyone finds out, post it here ...