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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:57:33+00:00 2026-06-09T12:57:33+00:00

I guess I do not completely understand the way require.js works. Here is a

  • 0

I guess I do not completely understand the way require.js works. Here is a a simple module I’ve created:

requirejs.config({
  paths: {
    'underscore'    : 'libs/underscore-min',
    'backbone'      : 'libs/backbone-min'
  }
});

define([
  "underscore",
  "backbone"
  ], function(_, Backbone) {
    console.log(_);
    console.log(Backbone);
    var MyCollection = Backbone.Collection.extend({
        initialize: function() {
            this.on("all", function(event) {
                console.log(event);
            });
        }

    });

    return MyCollection;
});

I load it from my html:

<script data-main="js/mycollection.js" src="js/libs/require.min.js"></script>

The problem is it works intermittently. Sometimes Backbone object is there in the function when I need it, sometimes it doesn’t (and gives me http://requirejs.org/docs/errors.html#notloaded error). If I just hit reload in the browser, I’d get 50/50 change of it working.

I must be missing something really basic here, the reported error doesn’t make any sense to me, I thought the whole idea of the require.js mechanism is that my function will be called only when all the dependencies are loaded.

  • 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-09T12:57:35+00:00Added an answer on June 9, 2026 at 12:57 pm

    My guess is that you’re not using an AMD version of underscore and Backbone. If that’s the case and the two packages aren’t wrapped as AMD modules – then the define function which is meant for modules won’t work like it should.

    For non-module js scripts, the more appropriate form would be to use the require() function.

    OR – you can find the AMD version of underscore and Backbone here. AMD support was taken out of Underscore and Backbone at some point.

    AMD Underscore

    AMD Backbone

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

Sidebar

Related Questions

I guess I'm not linking the Facebook SDK properly with my project. Here's the
I thought I understood sed but I guess not. I have the following two
[Edit] And, I should add, most elegantly? I guess (but not sure how) I
Since vector elements are stored contiguously, I guess it may not have the same
I guess the problem is that I do not know how to use factory
The definition of AudioBufferList looks weird to me… i guess my C is not
I want a solution for tag:hover that is not working on ie6. My guess
i understand that the code given below will not be compltely understood unless i
I guess this is not quite a programming question, but it is bothering me
I'm going to preface this with the fact that I am not completely knowledgeable

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.