I have a select field with id appointment_stylist_id. For some reason, the first one returns my element, and the second one returns undefined:
appointment_stylist_id
undefined
console.log(dojo.byId('appointment_stylist_id')); console.log(dijit.byId('appointment_stylist_id'));
Any idea why?
This is because it dojo.byIddoes what you want (find the DOM element with a specific identifier), and dijit.byIddoes not.
dojo.byId
dijit.byId
dijit.byId- This is a function to search for a specific widget by its assigned name (id). This function is similar to dojo.byId, but while dojo.byIdreturning DOMNodes, it dijit.byIdreturns a JavaScript object that is an instance of the widget....dijit.byId dojo.byId , . , JavaScript .
dijit.byId- This is a function to search for a specific widget by its assigned name (id). This function is similar to dojo.byId, but while dojo.byIdreturning DOMNodes, it dijit.byIdreturns a JavaScript object that is an instance of the widget.
...
dijit.byId dojo.byId , . , JavaScript .
http://dojotoolkit.org/reference-guide/dijit/byId.html
dojo.byId dijit.byId?
dojo.byId("appointment_stylist_id");
.
dijit.byId("appointment_stylist_id");
dijit.byId, :
dijit.byId("appointment_stylist_id").getValue();