I really can’t seem to grok RequireJS for some reason (having looked at various other questions)
Some background:
- I’m using jquery (so no Node.js automatic build stuff)
- I’m using a client-side mVC lib library (spine.js) which as part of it’s setup, in my case, does
require("Avail")deep inside it’s code. - ‘Avail’ is a javascript-class which is present globally as window.Avail
I’m getting the error-msg
Uncaught Error: Module name 'Avail' has not been loaded yet for context: _
http://requirejs.org/docs/errors.html#notloaded
I get that it isn’t loaded but how to do that? Is there a way to tell requireJS to register ‘Avail’ under the default context “_” when my app starts up?
I’ve tried several things like below (and lots of variations on that but I can’t get it to work):
(function() {
define("Avail", [],function(){
return window.Avail
});
})();
Help much appreciated. Thanks.
It turned out that even though Spine.js in it’s code already did a require on ‘models/Avail’, I had to do a require myself on ‘models/Avail’ as well.
file: spine.models.coffee
file: main.html