Legacy dojo 1.1 - dojo.addOnLoad fires when the dijit file is not ready

I have to use dojo 1.1 on the site.

The page uses dijit widgets in a declarative way, for example:

<select dojoType="dijit.form.FilteringSelect">...</select>

I want to do some things in widgets after loading, but if I do this:

dojo.addOnLoad(function() {
  dijit.registry.forEach(function(widget, idx, hash) {
    alert('Hello! I am a widget!');
  });
});

no warnings appear, since this code is executed before the "dijitification" on the page, as I found out during debugging.

Is there a way to execute my code when the page is really, really ready?

+1
source share
1 answer

Just in case, I (or someone else) will need it again, this is how I solved it:

dojo.addOnLoad(function() {
  dojo._loaders.push(someFunction);
});

This ensures that it someFunctionis executed after all other callbacks, including dijit callbacks.

+1
source

Source: https://habr.com/ru/post/1790122/


All Articles