Avoid decimal values in dijit/form/HorizontalSlide

2019-08-02 03:27发布

In dijit/form/HorizontalSlider on change I am getting values in a textbox. The values are decimal, like 51.66777777. I want only 51.

<div id="horizontalSlider"></div>
<input type="text" id="sliderValue" data-dojo-type="dijit.form.TextBox" style="width:190px;" onkeyup="getSliderTxtBoxValue();">

var slider = new HorizontalSlider({
                    name: "horizontalSlider",
                    value: 1,
                    minimum: 1,
                    maximum: 500,
                    discreteValues: 10,
                    intermediateChanges: true,
                    style: "width:200px;",
                    onChange: function(value){
                        dom.byId("sliderValue").value = value;
                    }
                }, "horizontalSlider");

See Also:

http://dojotoolkit.org/reference-guide/1.8/dijit/form/HorizontalSlider.html

1条回答
SAY GOODBYE
2楼-- · 2019-08-02 04:12

Have you ever seen Spinal Tap? This one goes to 11!

Here is the code that will work:

value: 0,
minimum: 0,
maximum: 500,
discreteValues: 11,

You want 11 because you want 11 discrete values:

0,50,100,150,200,250,300,350,400,450,500

I created a fiddle for this problem.

查看更多
登录 后发表回答