Dmitry Shulga
Dmitry Shulga

Reputation: 618

different steps in jquery ui slider

I use jQuery UI slider. I need to change steps in my case. I should have values of line:

var values = [0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];

I don't know how I can do it. I have found this decision. But here step is 1 and without float values. In my case 0.5 is the first. After that 1 (step 0.5) and then step is 1. How can I do it via js/jquery?

Thank you!

Upvotes: 2

Views: 3061

Answers (1)

Oleksandr  Maliuta
Oleksandr Maliuta

Reputation: 516

http://jsfiddle.net/KyKqq/473/

var sliderValue = [0.5, 1, 2, 3, 4, 26, 39, 52, 65];

$(function() {
        $( "#slider" ).slider({
            value:[ 0.5 ],      
            min: 0.5,
            max: 65,
            step : 0.5,
            slide: function( event, ui ) {
               if( sliderValue.indexOf(ui.value)===-1 ) return false;
               $( "#amount" ).val( ui.value)
            }
        });
        $( "#amount" ).val( $( "#slider" ).slider( "value" ) );
    });

Upvotes: 6

Related Questions