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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:33:05+00:00 2026-05-27T07:33:05+00:00

First sorry for my horrible english. This is the first time I’m using backbone.js.

  • 0

First sorry for my horrible english. This is the first time I’m using backbone.js.

I need to render a view to list my products but I need to fetch 2 selects () with product families and product types in the same place.

How can I fetch 3 collections in the same view? The fetches are asynchronous and need to capture the models on a successful response, but out the success method, I can’t read the response. Do I need to make nested fetches?

  list: function () {

var families = new FamilyList();

families.fetch({
    add: true,
    data: {
        'company_id': 1
    },
    success: function (model, response) {}
});

var types = new TypesList();

types.fetch({
    add: true,
    data: {
        'company_id': 1
    },
    success: function (model, response) {}
});

var pr = new ProductList();

pr.fetch({
    add: true,
    data: {
        'company_id': 1
    },
    success: function (model, response) {}
});

var json_template = {
    "title_list": "Company product manager",
    "types": types.models,
    "families": families.models,
    "products": pr.models,
};

html_content = Mustache.to_html(template_products, json_template);

$("#content").html(html_content);

}
  • 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-05-27T07:33:05+00:00Added an answer on May 27, 2026 at 7:33 am

    You will have to render your view in a callback function. You can listen to the reset event of your collections (triggered when fetch has finished) and trigger the rendering:

    list: function () {
    
      this.families = new FamilyList();
      this.families.bind('reset', this.render, this);
      this.families.fetch({
        add: true,
        data: {
          'company_id': 1
        }
      });
    
      this.types = new TypesList();
      this.types.bind('reset', this.render, this);
      this.types.fetch({
        add: true,
        data: {
          'company_id': 1
        }
      });
    
      this.pr = new ProductList();
      this.pr.bind('reset', this.render, this);
      this.pr.fetch({
        add: true,
        data: {
          'company_id': 1
        }
      });
    },
    
    render: function() {
      var json_template = {
        "title_list": "Company product manager",
        "types": this.types.models,
        "families": this.families.models,
        "products": this.pr.models,
      };
    
      html_content = Mustache.to_html(template_products, json_template);
      $("#content").html(html_content);
    }
    

    You should keep in mind that you are instantiating and binding your collections whenever you call the list() function. You should consider using the initialize() function of your view to create instances and bind to their events. See:

    http://documentcloud.github.com/backbone/#Collection-constructor

    With this approach the list will render 3 times (once for each collection). To optimize this you can keep track of the number of collections that have finished loading, and only render if all collection callbacks have been executed.

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

Sidebar

Related Questions

First of I'm very sorry but this questions is not so so specific. All
Sorry, this's my first time to ask a question here. So, I don't have
first of all sorry by my bad english, Hello i am new in this
first of all, sorry for my bad english, isnt my native language. Im using
First sorry for my bad English. I have this menubar in PHP. I want
first of all sorry for my english , not my main lang. I need
This is my first question here :D, first sorry about my english. My question
Well, first of all sorry about this question it must be pretty straight forward
first of all, sorry if that question is dumb but I´m a total newbie
First I'm so newb to iPhone dev and I'm sorry if this is easy.

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.