0

I'm trying to created a HorizontalSlider declarative that sends its values to a textbox, but I don't get any values in the textbox.

Here's my code:

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

What is wrong with that? I'm just seeing the Slider and it works itself, but it does not enter values into the textbox.

Simmal
  • 11

1 Answers1

0

Since your textbox is a dijit widget instead of using dom.by try using registry.byId from dijit/registry to set the value of the textbox.

<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"/>
Thomas Kagan
  • 440
  • 3
  • 16
  • I tried it, but that doesn't work either- When looking at it with Firebug I get the same error: "Uncaught ReferenceError: dom is not defined"/"Uncaught ReferenceError: registry is not defined" – Simmal Oct 15 '14 at 14:36
  • Can you create a jsfiddle with your work and provide the link in the comments – Thomas Kagan Oct 15 '14 at 14:39
  • Yes, i can. There's not all functionality of the application in it, but everything needed for that slider problem. http://jsfiddle.net/7qf1ouz9/ The slider can be found in the container named "Planungstool" – Simmal Oct 15 '14 at 14:58
  • And the html-code for the slider starts in line 28. – Simmal Oct 15 '14 at 15:03
  • The problem is that the "dom" module wasn't being loaded. Here you go http://jsfiddle.net/kagant15/7qf1ouz9/1/ – Thomas Kagan Oct 15 '14 at 15:43
  • well that is strange, because i added it with 'require(["dojo/dom"])' and it is now working in the fiddle but not in my application. did you change something more than loading it via 'dojo.require("dojo.dom")' and changing 'dom.byId' to 'dojo.dom.byId'? – Simmal Oct 15 '14 at 16:28
  • No that's all I changed. Are you getting the same error? – Thomas Kagan Oct 15 '14 at 17:03
  • OK. No, the error is now: "Error undefined running custom onLoad code: This deferred has already been resolved" – Simmal Oct 15 '14 at 19:11