Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8616589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:39:20+00:00 2026-06-12T05:39:20+00:00

I am trying to do a simple task. This task is to load a

  • 0

I am trying to do a simple task. This task is to load a HTML containg dijit.Form into a ContentPane. I don’t know which dijits I will need before I load this HTML, but the loaded HTML will contain applicable require‘s to load them.

So in order to be able to execute the script from loaded HTML I use dojox.layout.ContentPane. However when I set parseOnLoad to true, the parsing takes place before the script execution, so the dijits aren’t available when first loading the content. Also when I try to use onDownloadEnd callback, when this callback is run, the dijits from require‘s are still not loaded.

Only thing I can think of myself is using setTimeout to defer parsing to a time when these scripts will be executed. I don’t like this solution however as it may fail from time to time and it would make the application less responsible.

So how should I perform the parsing so that it happens right after the require statement from loaded HTML is run?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:39:21+00:00Added an answer on June 12, 2026 at 5:39 am

    I can see two possible solutions – both with dijit/layout/ContentPane:

    1. Use Dojo 1.8.0, as the parser supports auto require, it will load dependencies itself as you can see here: http://jsfiddle.net/phusick/vr4h4/

    2. Put the list of dependencies somewhere into your form template, e.g. in data-config attribute of your dijit/form/Form:

      <form 
          data-dojo-type="dijit.form.Form" 
          data-config='"deps":["dijit/form/Form", "dijit/form/TextBox", "dijit/form/Button"]'>
      
          <input data-dojo-type="dijit.form.TextBox" data-dojo-props="placeholder:'TextBox'">
          <button data-dojo-type="dijit.form.Button">Button</button>
      
      </form>
      

      Set parseOnLoad:false for the dijit/layout/ContentPane, load the template, get the list of dependencies, require them and then in the factory function parser.parse() containerNode of your ContentPane (see it in action http://jsfiddle.net/phusick/QA4gH/):

      require([
          "dojo/ready",
          "dojo/dom",
          "dojo/query",
          "dojo/on",
          "dojo/parser",
          "dojo/json",
          "dijit/layout/ContentPane",
          "dojo/domReady!"
      ], function(ready, dom, query, on, parser, JSON) {
      
          var template, dijits;
      
          ready(function() {
              template = dom.byId("template").textContent;
              on.once(dom.byId("loadFormButton"), "click", loadForm);
              contentPane1.set("parseOnLoad", false);
              contentPane1.on("load", parseForm);
          });
      
          function loadForm() {
              contentPane1.set("content", template);  
          }
      
          function parseForm() {
              // a node to parse
              var node = contentPane1.containerNode;
              // obtain a list of dependencies
              var config = JSON.parse("{" + query("form", node)[0].dataset.config + "}");
      
              // require (AMD load) dependencies
              require(config.deps, function() {
                  // parse ContentPane content when dependencies are resolved
                  dijits = parser.parse(node); 
                  console.log(dijits); // an array of instantiated dijits
              });
          }      
      });
      ​
      

    EDIT: I just got this idea that writing an auto require (for Dojo <1.8) is just about adding a short getDependencies() method, so you don’t need to list dependencies as I mentioned in the second option above:

    function getDependencies(/*DOMNode*/ containerNode) {
        var deps = [];
        query("[data-dojo-type]", containerNode).forEach(function(node) {
            var dep = node.dataset.dojoType.split(".").join("/");
            if(!~array.indexOf(deps, dep)) {
                deps.push(dep);
            };            
        });
        return deps;
    }
    

    See it working at jsFiddle: http://jsfiddle.net/phusick/hnjWt/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying this simple tutorial from oracle : http://www.oracle.com/technetwork/java/socket-140484.html (the Example 1 ).
Im trying to write a simple task killer. I know I shouldnt kill tasks
I am trying to complete a seemingly simple task that has turned into a
I'm trying to accomplish one simple task (but is not simple for me). I
I'm trying to accomplish a simple task of creating a database with 2 tables
I'm trying to do a simple task with jQuery: I have a list of
I have a very simple task I am trying to do in Groovy but
I'm trying to accomplish what should be a very simple task using the ListView
Currently I'm trying to do what I thought would be a simple task: Draw
After trying this simple console input with 5, the result is shown as 53

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.