Daryl
Daryl

Reputation: 18895

Why Is RequireJs Passing in Null?

I have two JS files:

Case.js

define(["require", "exports"], function(require, exports){
    var Case;
    (function (Case) {
        ...
    })(Case = exports.Case || (exports.Case = {}));
});

Ribbon.js

define(["require", "exports", "case"], function(require, exports, case){
    var Ribbon;
    (function (Ribbon) {
        function foo() {
            case.something();
        }
        Ribbon.foo = foo;
    })(Ribbon= exports.Ribbon|| (exports.Ribbon = {}));
});

I'm calling them in this manner:

require(["case"], function (case) {
    ...
});

// Sometime later as a result of a user click event
require(["ribbon"], function (ribbon){
    // *** ISSUE **** ribbon is undefined
    ribbon.foo();
});

But when I do, then the ribbon object is always undefined. From what I can tell, the only reason it would be null, is if there is a circular dependency, but I don't see one. Ribbon depends on Case, Case does not depend on ribbon.

Am I missing something?

Upvotes: 0

Views: 42

Answers (1)

Daryl
Daryl

Reputation: 18895

Problem solved... a co-worker of mine deployed a non-AMD version of Ribbon.js, which is why I wasn't getting my Ribbon object returned.

Upvotes: 1

Related Questions