dojo - dojo.byId()有效,但dijit.byId()不起作用

标签 dojo

我有一个ID为appointment_stylist_id的选择字段。由于某种原因,第一个返回我的元素,但是第二个返回undefined:

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

知道为什么吗?

最佳答案

这是因为dojo.byId完成了您想要的(找到具有特定ID的DOM元素),而dijit.byId却没有做到。

dijit.byId is a function for looking up a specific widget by its assigned name (id). This function is similar to dojo.byId but whereas dojo.byId returns DOMNodes, dijit.byId returns a JavaScript object that is the instance of the widget.

...

dijit.byId and dojo.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?

关于dojo - dojo.byId()有效,但dijit.byId()不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5724147/

相关文章:

javascript - javascript中选项对象的默认值

layout - Dijit.Dialog 中的 Dojo/Dijit BorderContainer

javascript - Dijit 选择,组合框中的项目已禁用 = true 不起作用

javascript - dojo.getAttr 不是一个函数

tree - 如何使用具有树扩展的 dgrid 执行 renderRow 方法的aspect.after?

javascript - 在不复制代码的情况下为不同的 Dojo 版本声明不同的类?

Dojo dStore Rest dGrid 排序参数

javascript - 获取 dojo comboBox 值

jquery-mobile - Sencha touch 与 Dojo Mobile 与 jQuery Mobile?

javascript - dijit.registry.filter/dijit.registry.map 不会迭代,尽管 dijit.registry 充满了已注册的小部件?