I have a slider from 1 to 0.1. I set the minimum and maximum and slider calculates the interval between numbers.
But now i need to use a set of numbers between 1/1, 1/2, ... to 1/9. (e.g. 1, 0.5, 0.33, 0.25, ...)
How can i make that ?
<div id="slider1" data-dojo-type="dijit.form.HorizontalSlider"
data-dojo-props='name:"horizontal1",
onChange:function(val){ dojo.byId("slider1input").value=dojo.number.format(val); },
maximum:1/9,
开发者_运维问答 minimum:1/1,
showButtons:true,
discreteValues:9,
intermediateChanges:true,
style:{width:"400px"}
'>
demo
Here is the modified example from the demo page:
<div id='slider1'
data-dojo-type='dijit.form.HorizontalSlider'
data-dojo-props='name:"horizontal1",
onChange: function(val){ dojo.byId("slider1input").value = dojo.number.format( 1 / (10 - val) ); },
maximum: 9,
minimum: 1,
showButtons: true,
discreteValues: 9,
intermediateChanges: true,
style: {width:"400px"}'>
<ol dojoType="dijit.form.HorizontalRuleLabels" container="topDecoration" style="height: 1.5em; font-size: 75%; color: gray;">
<li>1/9</li>
<li>1/8</li>
<li>1/7</li>
<li>1/6</li>
<li>1/5</li>
<li>1/4</li>
<li>1/3</li>
<li>1/2</li>
<li>1</li>
</ol>
<div dojoType="dijit.form.HorizontalRule" container="bottomDecoration" count=9 style="height:5px;"></div>
So the slider accepts integer numbers and then transforms them into your fractions, see onChange
function.
精彩评论