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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:34:00+00:00 2026-06-04T04:34:00+00:00

I have two datasets returning to two different backbone collections each using a different

  • 0

I have two datasets returning to two different backbone collections each using a different model. Both models share a field that could be used to link them.

The second ajax call is made after the first has loaded, as a sort of pre-loader.

Upon the second collection being successfully fetched (on ‘reset’ event), I’d like to somehow bind/join models (or simply copy the JSON in, it’s a one way read only thing) with the same value for the common field to a property on each of the other models where there is a match.

Just re-read that and I don’t think it reads very well, but hopefully you understand…

Collection 1

[
  {
    foo: 'text',
    bar: 'xxx'
  },
  {
    foo: 'text',
    bar: 'yyy'
  }
]

Collection 2

[
  {
    prop1: 'a',
    prop2: 'b',
    bar: 'xxx'
  }
]

Whether the raw data is added or a binding established, I desire the collection 1 JSON to be able to read like this

[
  {
    foo: 'text',
    bar: 'xxx',
    prop1: 'a',
    prop2: 'b',
  },
  {
    foo: 'text',
    bar: 'yyy'
  }
]

Or

[
  {
    foo: 'text',
    bar: 'xxx',
    extraProps: {
      prop1: 'a',
      prop2: 'b'
    }
  },
  {
    foo: 'text',
    bar: 'yyy'
  }
]

Any help greatly appreciated. All the ways I’m thinking it could be achieved don’t seem very backboney

PS: I’ve just noticed a backbone-relational tag while tagging this question. I’ll have a read there and post back if I see anything useful. It’s quite a hard question for form a good search phrase for…

EDIT

Thanks for the replies, I popped away to write a quick script and noticed that I had some replies before I’d even finished. Anyway, just for reference I will add my initial, perhaps quite bodgy script. Please ignore the fact that mailing/mailing_id don’t have the same field name, I am not in control of the data sources at this time…

<script>
var matches = 0;
_.each(clicks.models, function(click) {
  _.each(mailshots.models, function(mailshot){
    if(click.get('mailing') == mailshot.get('mailing_id')){
      matches++;
      click.set('subject',mailshot.get('mailing_subject'));
    }
  });
});
if(matches) clicks.trigger('reset');
</script>

Anyway, that works. But I’m just going to test the first reply and have a glance at backbone-relational. Might be more than I need now but looks interesting…

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

    when the two collections have been loaded you can do something like this

    _(collection2).each(function(v,i){
     var model = collection1.where({bar:v.get("bar")}).first();// assuming values of bar are unique
     model.set("prop1",v.get("prop1"));
     model.set("prop2",v.get("prop2"));
    })
    

    and to be more dynamic

     _(collection2).each(function(v,i){
         var model = collection1.where({bar:v.get("bar")}).first();// assuming values of bar are unique
         _.each(_.keys(v),function(k){
              model.set(v,v.get(k));
            });
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Python 2.6, and I have two datasets, each being a list of
I have two datasets each with one data table pulled from different sources and
I have two application that need to talk to each other. App1 needs to
I'm using table adapters and datasets in .NET (version 2.0). I have two tables
I have two example datasets, A and B below, that I want to join
I have a table that has its content filled using one of the two
I've got a bunch of strongly typed DataSet that each have two tables. One
I have a model with self-referencing ManyToMany field: class Suite(models.Model): suites = models.ManyToManyField(self, related_name=parents,
i have two datasets and i need to compare these two datasets such that
DESCRIPTION I have two datasets with information that I need to merge. The only

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.