I have a select field with id appointment_stylist_id
. For some reason, the first one of these returns my element but the second one returns undefined
:
console.log(dojo.byId('appointment_stylist_id'));
console.log(dijit.byId('appointment_stylist_id'));
Any idea why?
This is because dojo.byId
does what you want (find a DOM element with a particular ID), and dijit.byId
doesn't do that.
dijit.byId
is a function for looking up a specific widget by its assigned name (id). This function is similar todojo.byId
but whereasdojo.byId
returns DOMNodes,dijit.byId
returns a JavaScript object that is the instance of the widget....
dijit.byId
anddojo.byId
are often confused, particularly by first time users. This function should be used when you wish to obtain a direct handle the the JavaScript object instance of your widget and access functions of that widget.
http://dojotoolkit.org/reference-guide/dijit/byId.html
What the difference between dojo.byId and dijit.byId?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With