0

I've working on a thumb slider using yui/alloyui. According to the UC, the min and max parameters in the slider should be passed dynamically which means that I cannot hardcode them in the script. Reviewing the specs, it says the slider min, max, value parameters only accept numbers, not expressions. Can anyone help me accomplish this?

<code>
    mySlider = new Y.Slider({
        //min: 100,                      This works
        //max: 800,                      This works
        //value: 300,                    This works
        min: minValue,                   //Using a variable does not work
        max: maxValue,                   //Using a variable does not work
        value: (maxValue - minValue)/2,  //Using an expression does not work
        majorStep: 50,
        minorStep: 50,
        length: Y.one('#sliderParent').getComputedStyle('width')
    });
</code>

This is the jsfiddle: http://jsfiddle.net/bpkscskg/

Thanks for your help!

Adorablepolak
  • 157
  • 4
  • 16

1 Answers1

0

If you use an integer variable it should work. For example

   // my Variables
var myMin=+valMinAmount;
var myMax=+valMaxAmount;

xSlider = new Y.Slider({
    //min:100,
  min: myMin,
    max: myMax,
    //value: 
    majorStep: 50, //amount to increment/decrement the Slider value when the page up/down keys are pressed
    minorStep: 50, //amount to increment/decrement the Slider value when the arrow up/down/left/right keys are pressed
      length: Y.one('#sliderParent').getComputedStyle('width') // for responsiveness
});
pygator
  • 121
  • 3
  • Thanks a lot! It worked. By the way, is there a way to implement incremental steps (e.g. 100, 200, 300, and so on)? I don't find that in the API. – Adorablepolak Nov 24 '14 at 02:02