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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:55:34+00:00 2026-05-27T10:55:34+00:00

For a Titanium app that I’m writing, I’ve structured a modular approach to where

  • 0

For a Titanium app that I’m writing, I’ve structured a modular approach to where other developers (when I’ve moved on from my organisation or others have been asked to add onto the app) can add new modules to the app easily (not to be confused with native code modules).

I’m having difficulty figuring out how to load a module from an array and call a common central bootstrap-type method to initialise the module. The app uses the namespace approach as suggested by the authors of Tweetanium.

The app uses the namespace: org.app

I’ve defined an array that contains the configured modules that are to be loaded in the app:

org.modules = [
    {
        name: 'messages',
        enabled: true,
        title: 'Messages'
    },
    {
        name: 'calendar',
        enabled: true,
        title: 'Calendar'
    }
];

Each module has the namespace: org.module.moduleName where moduleName is the name of the module from the array (e.g. messages or calendar).

I have created a modules directory and I have been successful in dynamically including the js file for each module that is enabled (tested by specifically statically calling the method). I need to call the createModuleWindow() method from the module code to obtain the main view for that module.

org.module = {};
org.module.moduleManager = [];

// Loop through the list of modules and include the 
// main modulename.js file if enabled.
// Create the module and add it to the module manager array
var modules = org.modules;
var config = org.config;
for (var i = 0; i < modules.length; i++) {
    var _module = modules[i];
    if (_module.enabled) {
        Ti.include(config.moduleBasePath + _module.name + "/" + _module.name + '.js');
        org.module.moduleManager.push(createModuleWindow(_module.name));
    }
}

function createModuleWindow(moduleName) {
    // Not sure what to do here.
    return org.module.[moduleName].createMainWindow();
};

For createModuleWindow(), I’ve tried dynamic classes and the square bracket notation but I just get errors like ‘moduleName’ isn’t a constructor (in the case of using a class approach) or a parse error in the case of the above code.

How can I dynamically call the namespaced module method?

  • 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-27T10:55:35+00:00Added an answer on May 27, 2026 at 10:55 am

    Your syntax error is here:

    return org.module.[moduleName].createMainWindow();
                     ^
    

    There should be no dot:

    return org.module[moduleName].createMainWindow();
    

    A couple other notes:

    • org.module is empty in your example code, so the line above will throw a null-pointer exception. (You’re probably just not showing all your code.)

    • Use of both org.module (singular) and org.modules (plural) is needlessly confusing. I would try to better differentiate the two in the code.

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

Sidebar

Related Questions

I have a titanium based iOS app that basically is following my own MVC
I have been developing an app that supports streaming video and audio, among other
I have a simple mobile app in Titanium that I'm using to debug the
We have a sample app that loads 10 records each from the db and
I am writing an Titanium iPhone app when I want user to share his
Are you able to use titanium to build a mobile web app, such that
I have been trying to make sense of some claims that Appcelerator Titanium makes.
My mobile titanium app is loading data from a remote url, in the form
I'm working on a Titanium app and have build a function to run sqlite
I would lie to build a desktop app with Titanium and i thought 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.