YUI thumb slider does not accept variables and expressions

70 views Asked by At

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!

1

There are 1 answers

1
pygator On BEST ANSWER

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
});