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 8962615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:10:04+00:00 2026-06-15T16:10:04+00:00

I’m new to Backbone (still stuck in Ruby on Rails mode) and am a

  • 0

I’m new to Backbone (still stuck in Ruby on Rails mode) and am a bit confused about how to add a Collection to a Model as a property/attribute (is “attribute” the correct term?).

For example, I have a Model named current_plan, and a variable named json_dump that was returned from the server that includes an array of participants. I want it to have an attribute named participants (which is a Collection of participants), fill it from the json_dump.participants variable, and be able to use code like `current_plan.participants.where({first_name: “Dan”}).

Here are some snippets of my initialize function:

var current_plan = new Plan();

current_plan.set({attribute: val} ...other attributes... );
current_plan.participants = new Backbone.Collection(json_dump.participants);

But that forces me to access regular attributes like: current_plan.attributes.attribute. Also, I can see that there is correct data in the current_plan.attributes.participants.models, but I can’t figure out how to use any of the Collection methods on current_plan.

Clearly I don’t understand what’s going on, and why there are so many extra layers involved. The Backbone docs seem a little sparse, and I haven’t been able to find anything on SO or Google searches that match what I want to do. If there’s another question or tutorial out there that explains this, I’d greatly appreciate someone pointing me that way. I also saw the Backbone Relational project which seems like it may be what I need, but I’d prefer not to add more complication to Backbone until I understand the basics.

Thanks for any help you can provide to help a new Backbone user out!

  • 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-15T16:10:05+00:00Added an answer on June 15, 2026 at 4:10 pm

    the backbone framework doesn’t have a official way to handle relationships between models and collections i think, and i don’t use backbone relational, but i have multiple relationships in my backbone collections/models.
    when i am defining a relationship model with a collection i use it as a property of the model object, not a backbone atribute, so:

    var current_plan = new Backbone.Model(); //or backbone model extended 
    current_plan.participants = new Backbone.Collection(json_dump.participants);
    

    then as @andrew-hubbs says you should always use the backbone api to deal with models and collections attributes to have consistency in your code along with backbone versions for example.
    then you can access/set the model properties like this

    current_plan.get('property'); 
    participant = current_plan.participants.get(1);
    participant.get('property');
    participant.set('name', 'bob');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm parsing an XML file, the creators of it stuck in a bunch social

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.