Question

I have a multi handle jqueryui slider having range -30 to 50 , initially all handles set to zero. I want that if user slide any handle below zero then it automatically get set to zero.

jquery

 $(function () {
$("#mySlider").slider({
    min: -30,
    max: 50,
    values: [0, 0, 0],
    slide: function (event, ui) {
        $(ui.handle).text(ui.value);
    },
    stop: function (event, ui) {
        if (ui.value < 0) {
            //here I want to set handle to zero.
        };
    }
});

});

Fiddle:http://jsfiddle.net/trivender/6NftK/20/

Was it helpful?

Solution

Check this fiddle JSFIddle

$(function () {
$("#mySlider").slider({
    min: -30,
    max: 50,
    animate: true,
    values: [0, 0, 0],
    slide: function (event, ui) {
        $(ui.handle).text(ui.value);

    },
    stop: function (event, ui) {
        for(var i =0; i <= ui.values.length;i++)    
        {
             if(ui.values[i] < 0)
             {
               $("#mySlider").slider("values", i, 0);

             }
        }
    }
});

});

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top