I am trying to work with Jquery UI slider where I can have multiple handles:
$(function () {
var handlers = [25, 50, 75];
$("#slider").slider({
min: 0,
max: 100,
values: handlers,
slide: function (evt, ui) {
for (var i = 0, l = ui.values.length; i < l; i++) {
if (i !== l - 1 && ui.values[i] > ui.values[i + 1]) {
return false;
}
else if (i === 0 && ui.values[i] < ui.values[i - 1]) {
return false;
}
}
}
});
});
Please note that one handler can't overlap and I will need to set the handler dynamically on load, and save the handler positions on change.
The thing that i am trying to accomplish is to color the ui-content betweent the handler to different colors. I have attached the an Image.
Please advice if this is possible.
(⌐■_■) Hello there, my code attached below implements (i) 3 JQuery UI Slider handles which means 4 ranges, (ii) non-collision of range values, (iii) coloring of ranges, (iv) title tooltip on handle and (v) display of range values. Please note that I am using an old JQuery version. Also, it has a pattern which means it can likely be re-coded to support >=4 handles elegantly as well.
Bug: If handles are dragged to most left, they become "stuck", so you might want to have a reset button to restore handles' position.
One possibility would be to set the slider background to a CSS gradient and to update the gradient stops in code when the slider values change:
http://jsfiddle.net/LLfWd/60/
This code works for chrome and safari. My guess is you just have to generate multiple gradient strings (for -moz-linear-gradient, -ms-linear-gradient, etc...) the way I did it for -webkit-linear-gradient here.