开发者

What to change or add to slider so I have step motion in 5

Can someone help me with slider. What to change or add so I have step in 5 and to allow only integer numbers ? Currently, when I slide up or down step i about 3.6 . How to set value in slider from some function ?

<script type="text/javascript">
        dojo.require("dijit.form.Slider");
        dojo.require("dijit.form.TextBox"); // this we only include to make the textinput look prettier
        dojo.addOnLoad(function() {
            var vertical = dojo.byId("vertical");
            var rulesNode = document.createElement('div');
            vertical.appendChild(rulesNode);
            var sliderRules = new dijit.form.VerticalRule({
                count: 24,
                style: "width:5px;"

            },
            rulesNode);
            var slider = new dijit.form.VerticalSlider({
                name: "vertical",
                value: 0,
                minimum: 1440,
                maximum: 0,
                pageIncrement:100,
            showButtons:true,

  开发者_C百科          slideDuration:288,

                intermediateChanges:false,
                style: "height:450px;",
                                    onChange: function(value) {
                    dojo.byId("sliderValue").value = value;
                }
            },
            vertical);
        });
    </script>


You need to define how many discrete values you want to allow in the slider. This is done with the discreteValues parameter. In your case you have a range of 0 - 1440. If you want every number that is a multiple of 5 to be a valid value, this is 1440 / 5 = 288 discrete values.

But wait! That's not including the 0! You actually want the 288 steps + the first step which is 0. That makes 289 discrete values, and so your widget should be instantiated like this:

var slider = new dijit.form.VerticalSlider({
    /* .. your other properties.. */
    discreteValues: 289
}, vertical);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜