I have a problem showing in my console the data that the user puts in the input (only using Dojo, once the Submit button is pressed). Right now it shows "Name: [Widget dijit.form.TextBox, dijit_form_TextBox_2]"
My HTML code that is not dynamic:
<div class="NameContainer">
<label class="label1" for="name">Name:</label>
<input data-dojo-attach-point="nameInputData" type="text" name="name1"
data-dojo-type="dijit/form/TextBox"
data-dojo-props="trim:true, propercase:true"/>
</div>
<button data-dojo-type="dijit.form.Button" type="button" data-dojo-attach-point="submitButton" data-dojo-attach-event="onClick:_submitDetails">Submit</button>
JS function (I have also tried this.nameData.value, but it seems it does not exist):
_submitDetails: function () {
var nameData = this.nameData;
console.log("Name: " + nameData);
}
Use a
,instead of a+, that will pass a separate argument that is clickable on the screen instead of callingtoString()on the object to concatenate it with a string.I actually prefer the following since it gives you the name of the variable
For those with non-interactive consoles, such as node JS, you can use
JSON.stringifyto turn it into a readable string, as long as the object doesn't have cyclical references