【问题标题】:YUI thumb slider does not accept variables and expressionsYUI 拇指滑块不接受变量和表达式
【发布时间】:2014-11-23 01:36:56
【问题描述】:

我正在使用 yui/alloyui 制作拇指滑块。根据 UC,滑块中的 min 和 max 参数应该动态传递,这意味着我不能在脚本中对它们进行硬编码。查看规范,它说滑块最小值、最大值、值参数只接受数字,而不接受表达式。谁能帮我完成这个?

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

感谢您的帮助!

【问题讨论】:

    标签: javascript slider liferay yui alloy-ui


    【解决方案1】:

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

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

    【讨论】:

    • 非常感谢!有效。顺便问一下,有没有办法实现增量步骤(例如 100、200、300 等)?我在 API 中没有找到。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-24
    • 2023-03-07
    • 2018-05-18
    • 2021-03-23
    • 1970-01-01
    相关资源
    最近更新 更多