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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:31:20+00:00 2026-06-07T05:31:20+00:00

usually a requirejs module looks like: define(‘ModuleName’, [‘jquery’, ‘underscore’, ‘backbone’], function($, _, Backbone){ });

  • 0

usually a requirejs module looks like:

define('ModuleName', ['jquery', 'underscore', 'backbone'], function($, _, Backbone){

});

because every file in my setup requires underscore and backbone I would like to have them automaticly available in the module without having to define them as dependencies.

So something like:

define('ModuleName', ['jquery'], function($){
    $("div.someClass").addClass('hide'); // works
    var Model = Backbone.Model.extend(); // works too
});

Is this possible?

If yes how or what is the keyword I have to look for?

  • 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-07T05:31:23+00:00Added an answer on June 7, 2026 at 5:31 am

    The modules you’re interested in would have to be attached to an outer scope. By default, Backbone, Underscore, jQuery etc remain attached to the global scope unless you call noConflict() on them (not all modules provide this nicety). Attaching your modules to the global scope isn’t a great solution, but would accomplish what you’re asking for and is the default behavior anyway. The better alternative would be to define an outer module (or just a require() call) which contains those dependencies in addition to your named sub-modules. Otherwise, much of the reason for using RequireJS is lost.

    Edited for example:

    require(['underscore', 'backbone'],
        function (_, Backbone) {
            define('ModuleName', ['jquery'], function($){
                $("div.someClass").addClass('hide'); // works
                var Model = Backbone.Model.extend(); // works too
             });
    
            //Other modules here, otherwise this is pointless too
        }
    );
    

    Even this is only useful if you’re defining multiple named modules in the same file. The best solution from my perspective is unfortunately to explicitly import your modules and allow implicit module naming, but the above example is the closest to what you’re asking for. As for implicit module names, from the RequireJS api docs:

    You can explicitly name modules yourself, but it makes the modules
    less portable — if you move the file to another directory you will
    need to change the name.

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

Sidebar

Related Questions

I usually work with mongoskin because I like to be close to the database.
Now, I usually call a function (that requires no arguments) with () like this:
Usually I prefer to write my own solutions for trivial problems because generally plugins
Usually in a django view you would do something like queryset = MyModel.objects.something() How
Usually (if not always), when jQuery allows you to add a callback to some
OOP usually requires instantiation (creating an instance of class before using) like this: var
I have an entity representing Documents that looks like this: Document date_creation doc_number doc_origin
Usually I worked with PostgreSQL and never had a problem, but now I need
Usually, on twitter tweet button, if I don't specify data-text it take the page
Usually, as my code base grows, the functions recieve more and more arguments and

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.