y3di
y3di

Reputation: 673

RequireJS executing file code before dependencies are loaded/resolved

Requirejs seems to be allowing rels.js to run before Rel is loaded. https://github.com/yedi/Avalon/blob/backbone_rewrite/avalon/static/app/modules/collections/rels.js So Rel is undefined when I debug for it inside the initialize() function. model is also not being defined because Rel isn't defined.

I can't seem to understand why this is happening. Other files that are requiring the same Rel model don't seem to have this issue. (in both https://github.com/yedi/Avalon/blob/backbone_rewrite/avalon/static/app/modules/views/node.js and https://github.com/yedi/Avalon/blob/backbone_rewrite/avalon/static/app/modules/views/child.js, Rel is defined when I debug it. I require Rel the exact same way that I do inside rels.js)

I'm having this same issue with my items.js collection.

Any help/suggestions on how I can debug this problem? (I have no idea how I would even tackle it and I've been banging my head on this problem for a few days.)

Upvotes: 1

Views: 843

Answers (1)

ggozad
ggozad

Reputation: 13105

You simply have a circular dependency. Your collection requires the child model and vice-versa. Kill the "modules/collections/rels" requirement in the child model, it should not need to know how it will be contained in a collection.

Upvotes: 3

Related Questions