我正在尝试创建一个HorizontalSlider声明,将其值发送到文本框,但我在文本框中没有得到任何值。
这是我的代码:
<script type="text/javascript">
require([
"dojo/parser",
"dojo/dom",
"dijit/form/HorizontalSlider",
"dijit/form/TextBox"],
function(parser, dom, HorizontalSlider, TextBox)
{parser.parse();});
</script>
<input data-dojo-type="dijit/form/HorizontalSlider" id="slider_BM_FE" data-dojo-props="minimum: 0, maximum: 100000, value: 19423, intermediateChanges: true, onChange:function(value){dom.byId('BM_FE').value = value;}"/>
<br>
<input type="text" id="BM_FE" data-dojo-type="dijit/form/TextBox" style="width:100px; color:black"/>
这有什么问题?我只是看到Slider并且它自己工作,但它不会在文本框中输入值。
答案 0 :(得分:0)
由于您的文本框是dijit小部件而不是使用dom.by,请尝试使用dijit / registry中的registry.byId来设置文本框的值。
<script type="text/javascript">
require([
"dojo/parser",
"dojo/dom",
"dijit/form/HorizontalSlider",
"dijit/form/TextBox",
"dijit/registry"],
function(parser, dom, HorizontalSlider, TextBox, registry)
{parser.parse();});
</script>
<input data-dojo-type="dijit/form/HorizontalSlider" id="slider_BM_FE" data-dojo-props="minimum: 0, maximum: 100000, value: 19423, intermediateChanges: true, onChange:function(value){registry.byId('BM_FE').set({value: value})}"/>
<br>
<input type="text" id="BM_FE" data-dojo-type="dijit/form/TextBox" style="width:100px; color:black"/>