Opened 10 years ago

Closed 10 years ago

#14693 closed defect (invalid)

dijit.byId not available when async:true

Reported by: Kitson Kelly Owned by: Rawld Gill
Priority: undecided Milestone: tbd
Component: Dijit Version: 1.7.1
Keywords: Cc:
Blocked By: Blocking:


I might be wrong, but I don't think it is desired behaviour that when the loader is in async mode (async: true), and you require in "dijit", dijit.byId is not available.

For the following code, the first one returns undefined, the second one returns a function:

require(["dijit"], function(dijit) {

require(["dijit/_base/manager"], function(dijit) {

When async: false, dijit.byId is available in both.

Here is a working JSFiddle:

Change History (2)

comment:1 Changed 10 years ago by bill

Owner: set to Rawld Gill
Status: newassigned

Hmm, I think it's by design, the same way that <script src="dojo.js" djConfig="async: true"> doesn't load stuff like dojo.isDescendant().

Rawld, do you remember?

It's a strange example though. Since you are writing in AMD why don't you do this?

require(["dijit/registry"], function(registry){

comment:2 Changed 10 years ago by Rawld Gill

Resolution: invalid
Status: assignedclosed

Bottom line: bill is correct; if you want to use AMD require, then depend on the module that contains the API of interest. Here's the long version...


is a shortcut for "load the main module for the dijit package". If you look at the dijit package configuration at the bottom of dojo.js, you'll find:


Notice there is no main configuration, and therefore the package main variable defaults to "main". Therefore


is equivalent to


Looking at dojo/main, you'll find that the only thing that does is define the dijit object. So this is behaving correctly.

Recall that prior to 1.6, it was nonsense to do something like dojo.require("dijit"). Therefore, the whole idea of writing require(["dijit"]) is an AMD-thing.

Note: See TracTickets for help on using tickets.