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

The Archive Base Latest Questions

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

I’m currently trying RequireJS 2.0 and consequently have to change some code. Here’s my

  • 0

I’m currently trying RequireJS 2.0 and consequently have to change some code.
Here’s my main.js, launched with data-main in my index.phtml.

EDIT : Forgot project structure, can be useful 🙂

->public

 -> css
 -> js
 app.js
 facade.js
 main.js
 router.js
 ...
  -> collections
  -> libs

   -> backbone
   -> jquery
   -> json2
   -> plugins
   -> require
   -> underscore

 -> templates
...


// Filename: main.js

// Require.js allows us to configure shortcut alias
// There usage will become more apparent futher along in the tutorial.

require.config({
    //Here baseUrl = /js (Loaded in data-main in logged.phtml)
    // 3rd party script alias names (Easier to type "jquery" than "libs/jquery-1.7.2.min")
    paths: {
        jQuery: 'libs/jquery/jquery',
        Underscore: 'libs/underscore/underscore',
        Backbone: 'libs/backbone/backbone',
        JSON: 'libs/json2/json2',
        templates: '../templates'
    },

    // Sets the configuration for your third party scripts that are not AMD compatible
    shim: {
        'libs/plugins/bootstrap-min': ['jQuery'],
        'libs/plugins/jquery.cookies.min': ['jQuery'],
        'jQuery': {
            exports: '$'
        },
        'JSON': {
            exports: 'JSON'
        },
        'Underscore': {
            exports: '_'
        },
        'Backbone': {
            deps: ['Underscore', 'jQuery'],
            exports: 'Backbone'  // attaches "Backbone" to the window object
        }
    }
});

define([
    // Load our app module and pass it to our definition function
    'app',
    'jQuery',
    'Underscore',
    'Backbone',
    'JSON'
], function(App) {
    // The "app" dependency is passed in as "App"
    // Again, the other dependencies passed in are not "AMD" therefore don't pass a parameter to this function
    App.initialize();
});

I tried to add ‘router’ to this file with its dependencies but nothing has changed, so I assumed it was useless.

And here’s the app.js loaded when calling App:

define([
    'jQuery',
    'Underscore',
    'Backbone',
    'JSON',
    'router', // Request router.js
    'i18n!nls/langs',
    'facade',
    //'order!libs/plugins/jquery.backstretch.min'
    //'libs/plugins/backbone.validation.min'
], function($, _, Backbone, JSON, Router, langs, facade) {
var initialize = ...
...
...
return {
        initialize: initialize
    };
});

Here’s the problem, in my router.js definition, I used a console.log and it showed me that it was returning the right object.

But when I call router in my app.js, router stays undefined.
I probably made a mistake but I can’t find it.

EDIT : Added the router.js code

require([
    'jQuery',
    'Underscore',
    'Backbone',
    'JSON',
    'facade',
    'models/UserModel',
    'libs/plugins/jquery.cookies.min'
], function($, _, Backbone, JSON, facade, User, cookies){
    var AppRouter = Backbone.Router.extend({
...
    });

    var app_router = new AppRouter;
        // Start Backbone history a neccesary step for bookmarkable URL's
        Backbone.history.start();
    return app_router;
});
  • 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-09T00:57:42+00:00Added an answer on June 9, 2026 at 12:57 am

    Your router.js file isn’t defining an AMD module properly. You need to use define, not require.

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

Sidebar

Related Questions

I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.