2014-11-21 71 views
0

我已经在使用yui/alloyui的拇指滑块上工作。根据UC,滑块中的最小和最大参数应该动态传递,这意味着我无法在脚本中对它们进行硬编码。回顾规格说明,滑块最小值,最大值参数只接受数字,而不是表达式。任何人都可以帮我完成这件事?YUI拇指滑块不接受变量和表达式

<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> 

这是的jsfiddle:http://jsfiddle.net/bpkscskg/

感谢您的帮助!

回答

0

如果您使用整数变量,它应该工作。例如

// 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 
}); 
+0

非常感谢!有效。顺便说一句,有没有办法实现增量步骤(例如100,200,300等)?我在API中没有找到。 – Adorablepolak 2014-11-24 02:02:49