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

  • SEARCH
  • Home
  • 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 9274611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:23:39+00:00 2026-06-18T16:23:39+00:00

Ok, so I am trying to build something with Dojo 1.8 that will resemble

  • 0

Ok, so I am trying to build something with Dojo 1.8 that will resemble the following…

<ul class="groups">
  <li class="group">
    <ul class="items">
      <li class="item"></li>
    </ul>
  </li>
</ul>

I have made a simple TemplatedWidget for the “item” (lets call it TypeAItem, but there may be different types of “items” later on requiring different templates.

I have JSON that represents the groups, which looks like this…

[{
  name: "groupName",
  items: [{ title: "Item 1", type: "someRandomType", otherStuff: {} }]
}]

My problem is that I’m not sure what the best way would be to build this nested list.

Originally I just wanted to use some sort of looping convention like in Mustache, but Dojo’s templates don’t seem to support that. Then, after reading the Creating a Custom Widget tutorial I wanted to just use a nested for loop like so…

var groupHTML="<ul class='groups'>"
for (group in groups) {
  groupHTML += "<li class='group'>";
  for (item in groups.items) {
    ??? 
    // I'm assuming something like var item = new TypeAItem(item);
    //  but I the tutorial only uses the .placeAt(domNode) function
    // So I'm not sure how to get this to work.
  }
  groupHTML += "</li>
}
groupHTML += "</ul>

This would be easy enough where if I need a list of some other type of item type then I can just change that one line of code, or better yet, set this as a function and just pass in the widget that represents the item.

Since I don’t know how to get this to work, I started thinking I might need to setup the groups into their own widget, and then create the items in the postCreate method. However, then I need to figure out how to pass the group.items array to it, and also how to make it flexible enough to handle different item types later on.

If anyone could help I would greatly appreciate it!

  • 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-18T16:23:40+00:00Added an answer on June 18, 2026 at 4:23 pm

    To programmatically create domNodes, use the create method in dom-construct.

    In your widget, require: “dojo/dom-construct” as domConstruct

    // create the groups and place it on the page
    var groups = domConstruct.create("ul", {'class':'groups'}, this.someAttachPoint, 'last');
     // loop
     var group = domConstruct.create("li", {'class':'group'}, groups, 'last');
      // loop
      var items= domConstruct.create("ul", {'class':'items'}, group , 'last');
       // loop
       var item= domConstruct.create("li", {'class':'item',innerHTML:'item X'}, items, 'last');
       // or instead of innerHTML:  item.textContent = 'Some text'; // (check browser support)
    

    Note that domConstruct.create does not require you to place the node when it is created and ‘last’ is the default. You place it later using dojo place. Also, you can use dojo’s array functionality for the looping which allows you to get creative and have a helper function create these nodes.

    Depending on how different these groups and items are, you may still want to go with your idea of creating child widgets.

    Another approach is to use a dojox dtl template which allows you mix the code for the loop inside your template. These templates work like django templates (and you will need to reference the django docs to figure it out)

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

Sidebar

Related Questions

I'm trying to build something on javascript that I can have an input that
I'm trying to build something that I'm not sure if it's possible. I have
I'm trying to build something that will only fire a command once per keyboard
So I'm trying to build something that I made in photoshop. I'm trying to
I'm trying to build something that will randomly pick two objects from a list
I'm trying to build a web app using Dojo. I have a form that
I'm trying to build a progressbar class that can have an arbitrary number of
I've been whacking on this regex for a while, trying to build something that
I'm trying to build a view that operators something similar to this: The user
I'm trying to build something (ultimately a gem but for now an application) that

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.