Dojo.byId () works, but dijit.byId () is not

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:

  console.log(dojo.byId('appointment_stylist_id'));
  console.log(dijit.byId('appointment_stylist_id'));

Any idea why?

+5
source share
2 answers

This is because it dojo.byIddoes what you want (find the DOM element with a specific identifier), and dijit.byIddoes not.

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?

+14
dojo.byId("appointment_stylist_id");

.

dijit.byId("appointment_stylist_id");

.

dijit.byId, :

dijit.byId("appointment_stylist_id").getValue();
+1

All Articles