1

I have a jquery mobile slider :

<input type="range" name="slider" data-track-theme="c" 
        data-highlight="true" id="slider-step1" step="10000" 
        value="10000" min="10000" max="9000000" />

and I have to set the step value dynamically like this: Up to 200.000 steps of 10.000, up to 500.000 steps of 25.000, up to 1.000.000 steps of 50.000, up to 2.000.000 steps of 200.000, up to 9.000.000 steps of 500.000.

I tried a lot of things and nothing. Please help!

thecodeparadox
  • 86,271
  • 21
  • 138
  • 164
Iosif Petre
  • 188
  • 3
  • 8

2 Answers2

2

It's possible!! Try this solution with your value or variable:

$("#slider-step").attr("min", 4);
$("#slider-step").attr("max", 40);
$("#slider-step").attr("step", 4); 
$("#slider-step").val(4);
$('#slider-step').slider('refresh');

It works for me!!

Oibaf it
  • 1,842
  • 16
  • 9
0

Something like this might work.

$('#slider-step1').change(function(){
    currentValue = $(this).val();
    if(currentValue > 200000){
        $(this).attr('step','25000');
    }
    if(currentValue > 500000){
        $(this).attr('step','50000');
    }
    // and on and on 
});

I'm sure you will have to refine this to work as you want it to but this is the basic idea.

codaniel
  • 5,263
  • 1
  • 23
  • 32
  • i tried this, the result you can see here: http://admin.realmediastore.ro/test.htm, so it not working correctly because it sets the step after slider changed, I think... any idea? – Iosif Petre May 31 '12 at 22:54
  • I did a lot of work, it;s not about that, I think I need to use another event then Change, because I need to set the next step before changing the slider value... you know what I mean? – Iosif Petre Jun 05 '12 at 16:52