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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:28:27+00:00 2026-06-08T09:28:27+00:00

I am struggling with this one: I have this simple module in a file

  • 0

I am struggling with this one:

I have this simple module in a file Module1.js:

define(['dojo/_base/declare', 'esri/map'], function (declare, map) {
    return declare(null,
        {
            name: "Module 1 name",

            constructor: function() {
                this.name = "module 1";
                //this.age = age;
                //this.currentResidence = currentResidence;
            },


            doSomething: function() {
                alert("calling from Module1");
            }
        });
});

I am trying to define a Module2 that inherits from Module1 but cannot seem to find the correct syntax: This is what I currently have:

define(["dojo/_base/declare",
        "esri/map",
        "tut/Module1"],
    function (declare, map, Module1) {
        return declare(null, [Module1],     // or tut/Module1
        {
            name: "Module 2 name",

            constructor: function () {
                this.name = "module 2";
                //this.age = age;                 
            },


            doSomething: function () {
                this.inherited(arguments); // Call superclass method...
                alert("calling from Module 2");
            },

            doSomething1: function () {
                alert("calling do soething 1 from module 2");
            }
        });
});

Somewhere else in my code, I am doing this:

  require(["tut/Module1", "tut/Module2"], function (Module1, Module2) {        
        var m = new Module1();
        m.doSomething();

        var m2 = new Module2();
        m2.doSomething();    

    }); 

I have the following dojoConfig defined just before I load the ESRI script that loads dojo as follows:

     <script type="text/javascript">
   var dojoConfig = {
                async : true,                               
                packages: [{ name: "tut", location: liveString + '/scripts/xxxx/utilities'}]            
            };
 </script>
 <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.0compact"></script>

The call to Module1 works indicating to me that my packages definition is correct. However, the call to Module2 throws an exception that says Object [object object] has no method ‘doSomething’. I have tried some many different permutations, going back and forth with the manual but cannot find the right syntax. Now I am just guessing so will need some help.

How do I inherit from Module1 using Dojo 1.7 syntax?

  • 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-08T09:28:29+00:00Added an answer on June 8, 2026 at 9:28 am

    The call to this.inherited(arguments) will work (if declare doesnt throw ‘not a valid mixin’, and neither constructor method throws errors).

    Try

    module 1

    define(["dojo/_base/declare",
            "esri/map"],
        function (declare, map) {
            return declare("tut.Module1", [], {     // or tut>>.<<Module1
              constructor: function() { this.name='a'; console.log('a ctor'); }
              log: function() { console.log(this.name); }
            });
        }
    });
    

    module 2 derived from module 1

    define(["dojo/_base/declare",
            "esri/map",
            "tut/Module1"],
        function (declare, map, Module1) {
            return declare("tut.Module2", [Module1],
              constructor: function() { this.name='B'; console.log('B ctor'); }
              log: function() { this.inherited(arguments); console.log(this.name); }
            });
        }
    });
    

    Try iterating over the constructor._meta ‘bases’ in a module instance (‘new Module().constructor._meta’) and that should give an idea of how this.inherited works

    Calling

    require(["tut/Module2"], function (M2) {
       var m = new M2();
       console.log('created');
       m.log()
    });
    

    would output

    “B ctor”
    “A ctor”
    “created”
    “A”
    “B”

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

Sidebar

Related Questions

Im struggling with this one. I have a list of items and on a
This may seem like a very simple question, but I have been struggling with
Afternoon. Im struggling with this situation. I have a very simple tabbed content inside
Been struggling with this one I have the following DOM Structure: <ol id=add_images> <li>
I am struggling to get this one to work!! i know its simple... I
I am struggling to understand this simple regular expression. I have the following attempt:
I've been struggling with this one for a couple of days now. My current
Alright.. I'm struggling with this one.. I've got an image with a transparent hole
Hey, I'm really struggling with this one. I'am trying to port a small piece
I've been struggling for a while with this one; I'll try to explain it

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.