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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:04:26+00:00 2026-06-02T04:04:26+00:00

After several days of reading tutorials and searching The Google I have hit a

  • 0

After several days of reading tutorials and searching The Google I have hit a wall…

I’m creating an app using backbone.js that has an Item Model / Items Collection with various views to show the Items. A portion of the app will allow users to create groups (and use existing groups) to display a subset of the Items Collection.

There will be a Group Model / Groups Collection with various views to show the groups and allow users to associate Items with a specific group.

The problem is that each item can belong to one, many or none of the groups and I cannot figure out how to use the Group Model to get a subset of the Items Collection based on what items have been associated with it or this is even the right way to go about it.

Any help would really be appreciated!

  • 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-02T04:04:29+00:00Added an answer on June 2, 2026 at 4:04 am

    Depending on how many models you actually have, where you will be storing them, and how they will be rendered in the UI will depend on how you go about approaching this.

    If there are many models, which are stored in a database on a remote server, and items of groups will be rendered separately, one way would to go would be to load the items of the group on demand. Maybe something like …

    var Item = Backbone.Model.extend({});
    var ItemColleciton = Backbone.Collection.extend({
      url: '/load-items',
    });
    
    var Group = Backbone.Model.extend({
      items: new ItemCollection(),
      initialize: function() {
        // load the groups items as the group is initialized
        this.items.fetch({data:{groupID:this.id}});
      }
    });
    

    Alternatively, if you have fewer models, you may wish to load them all at once, and use filtering to populate the groups. Something like this …

    var Item = Backbone.Model.extend({});
    var ItemColleciton = Backbone.Collection.extend({
      url: '/load-groups',
    });
    
    var Group = Backbone.Model.extend({
      initialize: function() {
        // load the groups items as a subset of the already loaded group collection
        this.items = new ItemCollection(allItems.filter(function(item) {
          return item.GroupID = this.id;
        }, this));
      }
    });
    
    // in your router init ...
    var allItems = new ItemCollection();
    allItems.fetch();
    

    The above are just example approaches. What I found after using backbone for a while, is that it’s really open to interpretation, and can be implemented quite differently to solve different problems.

    You may also wish to check out backbone relational. I’ve not used it myself, but believe it has added support for mapping relationships between models and collection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java application that is working as a service. After several days
I am having a strange issue with jScrollPane plugin. After several days of using
After reading several questions regarding problems with compilation (particularly C++) and noticing that in
After several days of searching, trying and head-banging, I post this question to SO
I am creating several directories a day. After seven days I am going to
I suppose I have an interesting problem, and after several days of thinking and
I had an app that was Metadata rejected . After several rounds of correspondence
After using several non compatible barcode generators gems in rails 3.2, i am trying
After reading several articles of a hierarchical data tables, I've made my way into
After several days of tests I find the only way I can create a

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.