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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:29:47+00:00 2026-06-06T17:29:47+00:00

I have the following code in dojo creating a ComboButton with several MenuItems of

  • 0

I have the following code in dojo creating a ComboButton with several MenuItems of the correlated Menu:

    testfunc = function (input) {
                                //Code that uses input
            }

            var menu = new Menu({
                id: "saveMenu"
            });
            //array has 10 json objects and each object has an "Id" field
            for(var i=0; i<10; i++) {

            var temp = array[i]["Id"];

            var menuItem1 = new MenuItem({
                label: "Option"+i,                
                onClick: function() { testfunc(temp); }
            });

            menu.addChild(menuItem1);
            }

            var comboButton = new ComboButton({
                optionsTitle: "Options",    
                label: "Combo",
                dropDown: menu,
 --->         onClick:function(){ console.log("Clicked ComboButton"); }
            }, "combo");

            comboButton.startup();
            menu.startup();

I need for each MenuItem its onClick function to pass a different variable in the testfunc. Specifically the value of the array[i][“Id”] which is an array that has 10 json objects. With the above code the parameter that is passed in ALL the testfunc functions of ALL the MenuItems is the last one.

Is it possible to pass for each MenuItem the correct array[i][“Id”] value

i.e.

MenuItem0 -> onClick: testfunc(array[0][“Id”])

MenuItem1 -> onClick: testfunc(array[1][“Id”])

MenuItem2 -> onClick: testfunc(array[2][“Id”])

.

.

.

etc

Thanks

  • 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-06T17:29:48+00:00Added an answer on June 6, 2026 at 5:29 pm

    I have found a solution to my problem and I think I should share it.

    The issue was solved by passing in the testfunc of the onClick event of the menuItem the parameters using the “this” token e.g.

    var menuItem1 = new MenuItem({
    
                    id: array[i]["Id"],
    
                    label: "Option"+i,                
    
                    onClick: function() { testfunc(this.id, this.label); }
                });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in my page that creates a new Dojo/Dijit TabContainer.
I have following code that I am compiling in a .NET 4.0 project namespace
I have following code in a html form <select name=category class=input onchange=ShowTB(this,'suggest');> <option value=0
I have following code that displays an Image with letters, public class MainActivity extends
I have an HTML form using dojo and have the following code for a
I have the following subclass, derived from ContentPane: define([ dijit/layout/ContentPane, dojo/_base/declare ], function (ContentPane,
JavaScript For example, I have the following JavaScript code (Dojo 1.6 is already loaded):
I have the following code: dijit.byId('patient').onchange(function(event){ var term=dijit.byId('patient').get('value'); patientList.url = .calendar/search-patient?term=+term; patientList.close(); }) What
I have the following declarative js/dojo code running properly in Chrome: <div dojoType=dijit.form.TextBox> <script
I have the following code: <button data-dojo-type=dijit.form.Button data-dojo-props='baseClass:styleButton' name=_action_update type=submit label=Save >Save</button> The problem

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.