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 8872735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:17:36+00:00 2026-06-14T18:17:36+00:00

I have been using dojo 1.8 framework to create a widget that includes some

  • 0

I have been using dojo 1.8 framework to create a widget that includes some other menu widgets. When I create an instance of it it appears, but only shows the basic template elements, and under closer inspection, the menu widgets havent been added. Then when I make a second instance of it, (via button click), it appears correctly, including menus.

This is really confusing me, any ideas?

oh and I’m calling startup() on the widget instance by the way.

here is the code for my template…

<div class="${!baseClass}ConfigPanel">
        <div data-dojo-attach-point="heading">Configure data</div>
        <div id="menuContainer" data-dojo-attach-point="menu"></div>
</div>

here is the code for my widget…

define(
    ["dojo/_base/array",
    "dijit/Menu",
    "dijit/MenuItem",
    "dijit/PopupMenuItem",
    "dojo/_base/declare",
    "dijit/_WidgetBase",
    "dijit/_TemplatedMixin",
    "dojo/text!gdv/chart/configuration/panel/chartConfigTemplate.html",
    "dojo/domReady!"],
    function (ArrayUtil, Menu, MenuItem, PopupMenu, declare, WidgetBase, TemplatedMixin, template){

        var _menuData = [{title:"Region", data:["Region1", "Region2", "Region3"]},
                                        {title: "Variable", data:["variable1", "variable2", "variable3"]},
                                        {title: "Period", data:["period1", "period2"]},
                                        {title: ["latest", "rt1", "rt2"]}];


        /**
         * Build menu items up with a popup menu style
         */
        function buildMenu(nodeId, menuItems){
            var mainMenu = new Menu({label: "main menu"}, nodeId);
            var subMenuCollection = [];
            var subMenu;

            ArrayUtil.forEach(menuItems, function(item, index){
                subMenu = new Menu({label: item.title});
                subMenuCollection.push(subMenu);

                //loop through each item in data and create a new menu item from it
                ArrayUtil.forEach(item.data, function(subItem, subIndex){
                    subMenu.addChild(new MenuItem({label: subItem}));
                });

                //set the sub menu to popup from the main menu
                mainMenu.addChild(new PopupMenu({label: item.title, popup: subMenu}));

            });

            //create the menus
            mainMenu.startup();

            //start each sub menu
            ArrayUtil.forEach(subMenuCollection, function (item, index){
                item.startup();
            });
        }

        //return a new widget class
        return declare([WidgetBase, TemplatedMixin], {
            templateString: template,
            baseClass: "plumePlots",

            //when dom structure is ready but before page insertion
            postCreate: function(){

                //run all parent postCreate functions
                this.inherited(arguments);

                var menuNode = this.menu;
                buildMenu(menuNode.id, _menuData);
            }
        });
    }
)
  • 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-14T18:17:37+00:00Added an answer on June 14, 2026 at 6:17 pm

    Ok I’ve found the answer, it was down to the widget lifecyle, this quote straight from the dojo widget tutorial should help explain…

    startup()

    Probably the second-most important method in the Dijit lifecycle is
    the startup method. This method is designed to handle processing after
    any DOM fragments have been actually added to the document; it is not
    fired until after any potential child widgets have been created and
    started as well. This is useful for composite widgets as well as
    layout widgets.

    So it turns out I was trying to reference a dom element that had not been added to the document.

    To fix my code I simply moved the code creating the menu widgets from the postCreate() method into the startup() method, problem solved, and here is the code snippet showing the change…

    //return a new widget class
            return declare([WidgetBase, TemplatedMixin], {
                templateString: template,
                baseClass: "plumePlots",
    
                //when dom structure is ready but before page insertion
                postCreate: function(){             
                    //run all parent postCreate functions
                    this.inherited(arguments);
                },
    
                startup: function(){  // added startup function
                    var menuNode = this.menu; // code moved to here
                    buildMenu(menuNode.id, _menuData); // and here
                }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using some Javascript to create a text field once an certain
I have been using Twitter Bootstrap for some time. I heard a session that
I have been using the new nested fragment API that Android includes in the
I have been using TortoiseSVN for some time and I really like it. I
I have been using an API to do some work. This is how I
I have been reading about how the dojo 1.7 loader uses an AMD API/framework
I have been using Dojo hosted on Google's CDN. I just downloaded the development
I have been using HTML4 for quite some time. I've heard of HTML5 for
I have written an app using dojo that allocates a lot of data during
I have a set of items that can be dragged / dropped using Dojo

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.