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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:50:07+00:00 2026-06-01T12:50:07+00:00

I am looking to daisy chain Backbone requests in which the second request is

  • 0

I am looking to daisy chain Backbone requests in which the second request is dependent on the result of the first. How do I do it the right way? jQuery $.done() does not seem to work for me the right way. To explain better, here is a hypothetical example:

I have a list of suppliers and each supplier has a list of parts that they supply to the company. I want to fetch all the suppliers and then fetch all parts for this list of suppliers. Here is a sample code that I am trying to use without luck.

var App = {};

App.Supplier = Backbone.Model.extend({ });
App.Part = Backbone.Model.extend({ });

App.Suppliers = Backbone.Collection.extend({
   model: App.Supplier 
});

App.Parts = Backbone.Collection.extend({
    model: App.Part
})

var suppliers = new App.Suppliers;
var parts = new App.Parts;

var supplier_request = suppliers.fetch();

supplier_request.done(function(){
    parts.fetch_by_suppliers([supplier1, supplier2, ...]);
});

What happens is the second request fires immediately after the first reply has been received and before the App.Supplier models are instantiated. The result is — the supplier list remains empty and the second request fires off with the empty list of suppliers.

  • 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-01T12:50:08+00:00Added an answer on June 1, 2026 at 12:50 pm

    In order to accomplish this daisy chaining you’ll want to pass a success callback to the fetch method. The success callback gets passed (collection, response) as arguments. You can rewrite the code in your example in the following way:

    ...
    
    suppliers.fetch({success: 
      function(collection, response){
         parts.fetch_by_suppliers(collection);
      }
    });
    

    The Backbone.js documentation explains it pretty well. http://documentcloud.github.com/backbone/#Collection-fetch

    Hope this helps ya!

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

Sidebar

Related Questions

I'm looking for a restful way of passing through options to a service. Right
I'm looking for the right way to get an archive of a git repository
Looking for C# class which wraps calls to do the following: read and write
I'm looking for a way to input a 'schedule' for a task from a
Q. We're looking for a way to automate build process , run test cases
Heroku supports background workers and cron (daily, hourly) but I'm looking for a way
I'm looking for the best way to implement the following. I have a MySQL
I am looking for a way to do daily deployments and keep the database
I'm looking for a weather API which has information on what the weather is
Long story short, I am looking for the best way to quickly and efficently

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.