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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:44:47+00:00 2026-06-17T04:44:47+00:00

A little background information for the question So I wrote an application last year

  • 0

A little background information for the question

So I wrote an application last year for a client and about halfway through the project I realized that I would need to have a lot of asynchronous functionality so I started writing moving a lot of the site functionality over to javascript. I ran into a fairly major issue with my dev environment and ended up having a lot of my javascript inside my php files just to save time.

Before handing the project over to the client I moved all the javascript into seperate files only split up by the different areas of the site. So I ended up with an admin.js, checkout.js, common.js, etc.

The Actual Problem

The client now wants to add more functionality to the site and I want to go ahead and structure the javascript correctly into different files and separate the model code from the view code.

I’d like to use requirejs so I don’t have a bunch of script calls in the footer of every page and to also handle dependencies better.

The specific problem I’m having is that it doesn’t seem to be loading my files correctly.

My main.js file

require.config({
  paths: {
    'course'    : 'models/course',
    'login_view': 'views/login/login_view',
    'config'    : 'config',
    'views'     : 'views/views',
    'session'   : 'models/session'
  }
});

require(['login_view'], function(login_view){
  login_view.init();
});

My login_view.js file

define(function() {
  var login_view = {
    init: function(){
      console.log(this);
    });
  };
});

When I load the application on my dev server I get this error, Uncaught TypeError: Cannot call method 'init' of undefined

Any help would be appreciated.

  • 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-17T04:44:48+00:00Added an answer on June 17, 2026 at 4:44 am

    Because a module must expose an interface which requiring modules can operate on (variables names replaced to avoid confusion of naming):

    //login_view.js
    define(function() {
      var opBoard = {
        init: function(){
          console.log('I am initted!');
        });
      };
    
      //expose opBoard containing init
      return opBoard;
    });
    
    //so if i required in require or depended in another module
    require(['login_view'],function(lv){
      //lv is the exposed opBoard from the `login_view` module
      lv.init();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a little background information, I've got an application that's running in a loop,
Ok guys so a little background... I'm writing a small application that will assign
Background Information I have a distributed processing application that does data analysis. It is
Here is a little background information. I'm working on replacing a dll that has
little background: currently putting together a website that is selling products, many of which
Background I'm developing a research application that runs on Android phones. In short, the
Background I have been now using Entity Framework + Linq for about year and
A little background, this began in the question: Custom data type (Structures) vs arrays
first, a little background. I am using VS2010 and have a WCF service that
A little background information: I have a table called table_a , which has 12

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.