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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:34:23+00:00 2026-06-17T09:34:23+00:00

When creating new collection (Choices) I want to set a property on it (ex:

  • 0

When creating new collection (Choices) I want to set a property on it (ex: _question) which links back to the containing Model (MultipleChoiceQuestion)

  • 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-17T09:34:23+00:00Added an answer on June 17, 2026 at 9:34 am

    I actually found that although my 1st answer technically works, there’s a plugin that makes care of storing collections in models (and creating appropriate One->Many, One->One and Many->One relationships

    https://github.com/PaulUithol/Backbone-relational

    Using that plugin you store the parent question as an ATTRIBUTE

    m.MultipleChoiceQuestion = Backbone.RelationalModel.extend({
        relations: [{
            type: Backbone.HasMany,
            key: 'choices', //says to store the collection in the choices attribute
            relatedModel: m.Choice, //knows we are talking about the choices models
            includeInJSON: true, //when we do toJSON() on the Question we want to show serialize the choices fully
            reverseRelation: {
                key: 'question', //in the CHOICE object there will be an attribute called question which contains a reference to the question 
                includeInJSON: false //when we do .toJSON on a CHOICE we don't want to show the question object (or maybe we want to show the ID property in which case we set it to "id")
            }
        }],
        coolFunction: function () {
            this.get('choices').each(function(choice){
                choice.doSomethingChoicey();
            });
        }
    });
    

    So now if we are in the choices model we can fully reference anything in the parent question:

    m.Choice = m.RelationalModel.extend({
        coolFunction: function(){
            this.get('question').doSomemethingQuestiony();
            var question_numer = this.get('question').get('question_number');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there a way to uncap a capped collection? Creating a new collection and
In the _form for creating a new Contact, I want to be able to
I am creating a Will_Paginate::Collection object using the following code @paginatedResults = WillPaginate::Collection.new(1, 5)
When creating a mapping, I am reading that your collection property should look like:
Should a collection of objects also be responsible for creating new objects? Let me
How to do that without creating any new collections? Is there something better than
I have been creating a peer to peer connection for a new game, that
when i am creating new android project from visual studio 2010 it gives the
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
When I'm creating new project with GWT plug in it creates a skeleton project

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.