Quick question... I have a define for requirejs setup like so... it works about 8-10% of the time. It seems that a resource sometime isn't loaded in time. Can I wrap the above var require list in a way that ensures the code below it will run correctly? The error I get when it doesn't work is this:
Uncaught Error: Module name "views/association/Associations" has not been loaded yet for context: _
define(function( require ){
// requirejs - too many includes to pass in the array
var $ = require('jquery'),
_ = require('underscore'),
Backbone = require('backbone'),
namespace = require('namespace'),
// models
CustomerModel = require('models/customer/customer'),
// collections
// views
BaseView = require('views/baseView'),
Auth = require('views/auth/Auth'),
SideNav = require('views/sidenav/SideNav'),
CustomersView = require('views/customer/Customers'),
AssociationsView = require('views/association/Associations'),
//CustomerListCpeView = require('views/customer/CustomerListCpe'),
//CustomerAddCpeView = require('views/customer/CustomerAddCpe'),
// templates
CustomerDetailTemplate = require('text!templates/customer/customerDetail.html');
Even with the "traditional" or non-sugar method (http://requirejs.org/docs/whyamd.html#sugar), this error persisted. It turned out that there was a circular import that I accidentally introduced into the codebase during a refactor. Removing that circular import removed this error.
Change it to
define([
'jquery',
'underscore',
'backbone',
// ...
'views/association/Associations'
// ...
], function($, _, Backbone, /* ..., */ AssociationsView) {
// ...
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With