2014-11-21 69 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