[Solved] If I call function inside document ready it will not work, but if I call it on an event it works just fine [closed]


Your problem is that dijit.form.TextBox has not been loaded when the rest of the DOM has loaded. You’ll need to change your my_func code to include a call to require:

function my_func() {
    require(['dijit/form/TextBox'], function(TextBox) {
        // ...
        var newBox = new TextBox();
        // ...
    });
}

You’ll need to do this for every Dojo class. For example, if you also need dijit.form.Button:

function my_func() {
    require(['dijit/form/Button', 'dijit/form/TextBox'], function(Button, TextBox) {
        // ...
    });
}

It’s a little unfortunate that it’s this verbose, but that’s the way it goes. More information about require is available in Dojo’s documentation.

2

solved If I call function inside document ready it will not work, but if I call it on an event it works just fine [closed]