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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:46:37+00:00 2026-06-17T16:46:37+00:00

I have been staring at this for a while and can’t seem to figure

  • 0

I have been staring at this for a while and can’t seem to figure out why some AMDs aren’t available after loading them as dependencies. I have a custom module called “models”; a bundle configured in my MVC project with the virtual path “/scripts/models.js”. When I define it in require.config and as a dependency, it loads the file. I can see it was requested and found. No errors from require. However, when I try to reference it as the loaded dependency argument passed into my router, it’s undefined (models.userModel).

Is there something I am doing wrong here? I don’t see any circular dependencies and I have tried defining the models module by giving it a name. It is undefined regardless if I define it globally or request the module by path in my router.js file.

app.js. Main config. (below)

require.config({
    baseUrl: "/scripts/app",
    paths: {
        jquery: "../jquery",
        underscore: "libs/underscore",
        backbone: "libs/backbone",
        kendo: "libs/kendo",
        models: "../models"
    },
    // We shim Backbone since it doesn't declare an AMD module
    shim: {
        underscore: {
            exports: "_"
        },
        backbone: {
            deps: ["underscore", "jquery"],
            exports: "Backbone"
        }
    },
});

require([
    "jquery",
    "backbone",
    "kendo",
    "models",
    "router"
], function ($, backbone, kendo, models, router) {  
    alert("config-start");
});

user.js. Indcluded in the models.js bundle. (below)

define({
    userModel : kendo.observable({
        datasource: kendo.data.DataSource({
            transport: {
                read: {
                    url: "/api/usersettings",
                    dataType: "json",
                    type: "GET"
                },
                update: {
                    url: "/api/usersettings",
                    dataType: "json",
                    type: "PUT"
                }
            },
            schema: {
                model: {
                    id: "UserId"
                }
            },
            parameterMap: function (options, operation) {
                if (operation !== "read" && options.models) {
                    return {
                        models: kendo.stringify(options.models)
                    };
                }
                return options;
            }
        }),
        save: function () {
            this.data.sync();
        },
    })
});

router.js file (below)

define(["jquery",
    "backbone",
    "models"
], function ($, backbone, models) {

    /**
     * The Router class contains all the routes within the application -
     * i.e. URLs and the actions that will be taken as a result.
     *
     * @type {Router}
     */

    var Router = Backbone.Router.extend({
        contentArea: $("#MainContent"),
        routes: {
            "user/usersettings/contact": "contact",
            "user/usersettings/security": "security",
            "user/usersettings/dashboard": "dashboard",
            "user/usersettings/permissions": "permissions",
            "user/usersettings/colors": "colors"
        },
        contact: function () {
            var contactTemplate = kendo.template($("#usersettings-usercontact").html());
            this.contentArea.empty();
            this.contentArea.html(contactTemplate);

            kendo.bind(this.contentArea, models.userModel); // models is undefined
        },
        security: function () {

        },
        dashboard: function () {

        },
        permissions: function () {

        },
        colors: function () {

        }
    });

    // Create a router instance
    var router = new Router();

    //Begin routing
    Backbone.history.start();

    return router;
});

Maybe I am missing something obvious, but I have not been able to load “models” as an external dependency. It is undefined when referencing from router.js. On the “contact” function.

  • 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-17T16:46:37+00:00Added an answer on June 17, 2026 at 4:46 pm

    Define needs a function that will return a value, this value then will be injected when it was required in another module.

    Source code comment:

    /**
     * The function that handles definitions of modules. Differs from
     * require() in that a string for the module should be the first argument,
     * and the function to execute after dependencies are loaded should
     * return a value to define the module corresponding to the first argument's
     * name.
     */
    
    define(function(){
      return {
        userModel: ...
      }
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been staring at this for quite a while and can't figure out how
I have been staring at this code and cannot figure out what is wrong
I've been staring at this thing for a while now and I can't seem
I have been picking my brain lately and can't seem to figure out how
I have been thinking about this issue and I can't figure it out. Perhaps
I have been learning python for some time now. While starting this learning python
Maybe someone can clear me up. I have been surfing on this a while
I have been trying this for a while now and can't get it to
I've been working on this problem for a while and can't seem to find
I have been looking at this for a while and can't see where the

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.