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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:30:40+00:00 2026-05-31T01:30:40+00:00

I am really a newbie to dojo but as i started developing a new

  • 0

I am really a newbie to dojo but as i started developing a new application with dojo version 1.7.2 i also wanted to use the new AMD syntax for functions. Unfortunately i don’t seem to get it. 🙁

What annoys me most is that i can’t simply call any function which is inside of a “require”-block.
For example i have a page which on opening creates a dynamic table with several widgets in each row.
Then i have a button which adds one empty row each time pressed.

Without AMD syntax it would be easy:
– put all my “dojo.require()” in the HEAD
– and then create a bunch of my own functions for creating the table and widgets
– the add row function could easily access any global-variables my previous function filled

But with AMD its like this:

Initial function creates the table and widgets:

function fillReportTable(repId) {
require(["dojo/dom-construct", "dojo/dom-attr", "dijit/form/FilteringSelect",
"dojo/data/ItemFileReadStore", "dijit/form/ComboBox", "dijit/form/DateTextBox", "dijit/form/Select", "dojo/store/Memory"],
     function (domConstruct, domAttr, FilteringSelect, ItemFileReadStore, ComboBox, DateTextBox, Select, Memory) {
   // a lot of code to create the table, consisting of SEVERAL functions 
   function createNewRow(tbl) { ...} 
   function function1 () {... } 
   function function2 () {... } 
   function function3 () {... } 
}

Now the “Add Empty Row” button calls its own function “addEmptyRow”.
But in this function I have to:
– do an other require for each dojo-module again
– I CAN’T use any of the functions which are “inside” of the “fillReportTable”-function. For example the “createNewRow”-function

 function addEmptyRow() {
require(["dojo/dom-construct", "dojo/dom-attr", "dijit/form/FilteringSelect",
"dojo/data/ItemFileReadStore", "dijit/form/ComboBox", "dijit/form/DateTextBox", "dijit/form/Select", "dojo/store/Memory"],
     function (domConstruct, domAttr, FilteringSelect, ItemFileReadStore, ComboBox, DateTextBox, Select, Memory) {
// a lot of code to create the table, consisting of SEVERAL functions
}

This all seems to be so much complicated with AMD.
Or am i missing something obvious here ?
With AMD if you separate your code into a lot of small functions, do you do the “require” inside EACH function all over again ? Or do you put all the functions inside one “require” with the full list ?
If you do it the second way, how can you call these functions from widget events?

  • 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-05-31T01:30:42+00:00Added an answer on May 31, 2026 at 1:30 am

    The easiest way would be to define your own module. Take a look at this tutorial first:

    http://dojotoolkit.org/documentation/tutorials/1.7/modules/

    Now define your own module, e.g. “./js/mymodules/mymodule.js” (relative to HTML page):

    define([
        "dojo/dom-construct",
        "dojo/dom-attr",
        "dijit/form/FilteringSelect",
        "dojo/data/ItemFileReadStore",
        "dijit/form/ComboBox",
        "dijit/form/DateTextBox",
        "dijit/form/Select",
        "dojo/store/Memory"
    ], function (domConstruct, domAttr, FilteringSelect, ItemFileReadStore, ComboBox, DateTextBox, Select, Memory) {
    
        function fillReportTable(repId) {
           // a lot of code to create the table, consisting of SEVERAL functions 
           function createNewRow(tbl) { ...} 
           function function1 () {... } 
           function function2 () {... } 
           function function3 () {... } 
        }
    
        function addEmptyRow() {
           // a lot of code to create the table, consisting of SEVERAL functions
        }
    
        // Return an object that exposes two functions
        return {
            fillReportTable: fillReportTable,
            addEmptyRow: addEmptyRow
        }
    
    });
    

    And use your module like this:

    <html>
    
    <head>
    
    <script>
    var dojoConfig = {
        baseUrl: "./js/",
        packages: [
            { name: "dojo", location: "lib/dojo" },
            { name: "dijit", location: "lib/dijit" },
            { name: "dojox", location: "lib/dojox" }
        ]
    };
    </script>
    
    <script data-dojo-config="async: true" src="js/lib/dojo/dojo.js"></script>
    
    </head>
    
    ...
    
    <script>
    require([
        "mymodules/mymodule"
    ], function (mymodule) {
        mymodule.fillReportTable(...);
        mymodule.addEmptyRow(...);
    });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry, really newbie question, but if I was to create an ASP.NET website application,
This is probably a really newbie question (well, I'm pretty sure it is), but
This is probably a really stupid newbie-sounding question to you developer type people, but
I'm really new to VSTO so sorry if this is a newbie question. I'm
I'm a complete Xcode/Objective-C/Cocoa newbie but I'm learning fast and really starting to enjoy
A newbie question (I haven't really created new projects in Eclipse yet): I have
i'm newbie developer.... i really need help at now... i just get started with
Sorry fot his newbie question. But I really need a start on this one.
This is really a dumb newbie question, but I am still learning the ropes
I'm really new at network-programming, so I hope this isn't a complete Newbie-question. I

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.