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

  • SEARCH
  • Home
  • 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 8321789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:08:53+00:00 2026-06-08T23:08:53+00:00

I have the following setup (pseudo coffee code). Models and collections are loaded using

  • 0

I have the following setup (pseudo coffee code). Models and collections are loaded using Require.js.

ParentModel = Backbone.Model.extend

ParentCollection = Backbone.Collection.extend

CollectionA = ParentCollection.extend
    model: ModelA

CollectionB = ParentCollection.extend
    model: ModelB

CollectionC = ParentCollection.extend
    model: ModelC

ModelA = ParentModel.extend
    defaults:
        collectionB: new CollectionB()
        collectionC: new CollectionC()

ModelB = ParentModel.extend
    defaults:
        collectionA: new CollectionA()

ModelC = ParentModel.extend
    defaults:
        collectionA: new CollectionA()

ModelA has two collections with ‘child’ models. ModelB and ModelC has the vice versa: one collection with ‘parent’ models. ModelA works fine, but ModelB and ModelC generate two errors. The first by Firebug’s spy.js: “Module name ‘modelB’ has not been loaded yet for context: _” and the second by Require.js: “Module name ‘collectionB’ has not been loaded yet for context: _”. If I don’t load the collections in model B and C, there are no errors and the app works. I’m trying to solve the error, but I don’t know what is going wrong. Is it a Backbone.js circular reference issue or a Require.js circular dependency or maybe something else?

EDIT

Code for organisation.coffee (modelA)

define (require) ->
    _ = require 'underscore'
    mGroup = require 'models/object/group/group'
    cDepartement = require 'collections/object/group/departement'
    cProject = require 'collections/object/group/project'

    mGroup.extend
        'urlRoot': '/api/organisation'
        'defaults': _.extend({}, mGroup.prototype.defaults,
            'type': 'organisation'
            'departements': new cDepartement()
            'projects': new cProject())

Code for project.coffee (modelB)

define (require) ->
    _ = require 'underscore'
    mGroup = require 'models/object/group/group'
    cOrganisation = require 'collections/object/group/organisation'

    mGroup.extend
        'urlRoot': '/api/project'
        'defaults': _.extend({}, mGroup.prototype.defaults,
             'type': 'project'
             'organisations': new cOrganisation())

If I comment out the cOrganisation = require… and new cOrganisation than everything works. Projects, departements and organisations are all groups, but organisations are parents of projects and departements.

  • 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-08T23:08:55+00:00Added an answer on June 8, 2026 at 11:08 pm

    Yes. Just move defaults to initialize method. There it’ll be used when all definitions are loaded. Something like:

    ModelB = ParentModel.extend
      initialize(options) ->
        options = options || {}
        if options.collectionA
          this.collectionA = options.collectionA
        else
          this.collectionA = new CollectionA()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following models setup in my Django application class School(models.Model): name = models.TextField()
I have following setup. from django.db import models from django.contrib.auth.models import User class Event(models.Model):
I have following setup in my Backbone View: var SomeView; SomeView = Backbone.View.extend({ initialize:
i have following model setup class Category < ActiveRecord::Base has_ancestry :cache_depth => true, :depth_cache_column
I have the following setup: Code on my local machine (OS X) shared as
I have the following setup for Moq: ... other code to setup bigMoq object
I have the following setup: app/assets/stylesheets/application.css.scss /* *= require_self *= require fancybox */ /*
I have the following setup: Development: My own computer using an MDF file with
I have following setup, but when I put 1024 and replace all 512 with
I have the following setup: Table: Question QuestionId Table: QuestionTag QuestionId TagId Table: Tag

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.